Bonjour,
J'ai écrit un progrmme permettant de faire plusieurs remplacement de texte sous Word.
Mais quand j'execute le programme il ne fait rien.
Si quelqu'un a une solution...
Merci
PS Voici mon code:
Sub Modification_word()
Set app_wrd = CreateObject("Word.application") 'Demande à communiquer avec word.
app_wrd.DisplayAlerts = wdAlertsNone ' Affiche les messages d'alertes ou pas.
If Afficher_messages = True Then
app_wrd.Visible = True ' Affiche word.
Else
app_wrd.Visible = False ' Cache word.
End If
app_wrd.Visible = True
app_wrd.Documents.Open ("c:\TOTO.doc) ' Ouvre le fichier
Numero = FreeFile ' Recupère un numéro unique disponible.
Open Fichier_remplacement For Input Access Read As #Numero ' Ouvre le fichier en lecture.
Do While Not EOF(Numero) ' Vérifie si la fin du fichier est atteinte.
Line Input #Numero, Lecture_ligne ' Lit chaque lignes de données.
Position = InStr(1, Lecture_ligne, "=", vbTextCompare)
If Position <> 0 Then
Rechercher = Trim(Mid(Lecture_ligne, 1, Position - 1))
Remplacer = Trim(Mid(Lecture_ligne, Position + 1))
If StrConv(Rechercher, vbUpperCase) <> "@SIGNATURE" Then
app_wrd.Selection.Find.ClearFormatting
app_wrd.Selection.Find.Replacement.ClearFormatting
With app_wrd.Selection.Find
.Text = Rechercher
.Replacement.Text = Remplacer
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
app_wrd.Selection.Find.Execute Replace:=wdReplaceAll
Else
Signature = Remplacer ' Récupère le fichier bitmap à insérer.
End If
End If
Loop
Close Numero ' Ferme le fichier de remplacement
app_wrd.Application.ActiveDocument.SaveAs FileName:=Fichier_Excel_word
End Sub
Sebastien
