Sub génération_fi()
'Macro de génération de FI
Dim x As Integer
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim chemin As String
Set WordApp = CreateObject("word.application")
With WordApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set WordDoc = WordApp.Documents.Open("W:\05 - Méthodes\11 - Méthodes\Glossaire\612 MTH rev B.docx")
chemin = Replace(Range("O3"), "\", "\\")
'La variable x va successivement prendre les valeurs 3 à 10
For x = 10 To 216
'Ecrit dans la plage de cellules A3:A10
'( Cells(3, 1) correspond à la cellule A3,
'Cells(4, 1) correspond à la cellule A4 ... etc... )
If Cells(x, 7) = "X" Then
Cells(x, 6).Select
a = Cells(x, 6).Value
WordDoc.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"INCLUDETEXT " & Chr$(34) & Range("O3") & Chr$(34) & " " & a, PreserveFormatting:=True
End If
Next x
End Sub