Sub recherchedocword()
With Application.FileSearch
.LookIn = "C:\Documents and Settings\ledzepfred\bureau\A TRAITER"
.FileName = "*.doc"
.Execute
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Documents.Open FileName:=.FoundFiles(i)
Call renommeobjet
ActiveDocument.Close True
Next
End If
End With
End Sub
Sub renommeobjet()
Dim FF As FormFields
Dim Indice, i, j, k As Long
Dim mavar As Variant
Indice = 0
i = 0
j = 0
k = 0
If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect
Set FF = ActiveDocument.FormFields
For Indice = 1 To FF.Count
FF(Indice).Select
Select Case FF(Indice).Type
Case wdFieldFormTextInput
mavar = FF(Indice).Result
i = i + 1
With Dialogs(wdDialogFormFieldOptions)
.Name = "Texte" & i
.Execute
End With
FF(Indice).Result = mavar
Case wdFieldFormCheckBox
mavar = FF(Indice).CheckBox.Value
j = j + 1
With Dialogs(wdDialogFormFieldOptions)
.Name = "CaseACocher" & j
.Execute
End With
FF(Indice).CheckBox.Value = mavar
Case wdFieldFormDropDown
mavar = FF(Indice).DropDown.Value
k = k + 1
With Dialogs(wdDialogFormFieldOptions)
.Name = "Liste" & k
.Execute
End With
FF(Indice).DropDown.Value = mavar
End Select
Next Indice
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub