Bonjour Bayard,
Je confirme : le VBA est bien le même en WORD qu'en EXCEL (même chose pour OUTLOOK, POWERPOINT, ACCESS).
Donc, pour ton problème, je te suggère :
- Nom donner un titre à la liste déroulante des Noms (dans l'exemple joint j'ai arbitrairement choisi 'NomAdherent')
- Tu modifie le Module1 de la façon suivante :
Sub VersPDF()
Dim nfichier As String, intpos As Byte
Dim sNom As String
sNom = RecupNomAdherent
nfichier = ActiveDocument.Name
'trouve la position de l'extension
intpos = InStrRev(nfichier, ".")
nfichier = Left(nfichier, intpos - 1) & "_" & sNom
'enregistre dans le dossier en cours
'ActiveDocument.SaveAs2 FileName:=nfichier, fileformat:=wdFormatPDF
ActiveDocument.ExportAsFixedFormat OutputFileName:=nfichier, ExportFormat:=wdExportFormatPDF
End Sub
Function RecupNomAdherent() As String
Const cNomControl = "NomAdherent"
Dim oControl As ContentControl
For Each oControl In ThisDocument.ContentControls
If oControl.Title = cNomControl Then
RecupNomAdherent = oControl.Range.Text
End If
Next
End Function
NB : Si tu choisis un autre titre que le mien, n'oublies pas de modifier la valeur de la constante 'cNomControl' en conséquence...