Afficher un message
Vieux 27/07/2004, 18h59   #2 (permalink)
michel
Guest
 
Messages: n/a
Par défaut Re: La méthode find and replace de word depuis excel

bonsoir Knecmotet

ci joint un exemple de macro pour remplacer un mot dans un document Word ( adapté de l'aide en ligne VBA )


Sub RemplacerMotDocWord() ' en projet
'necessite d'activer la reference microsoft Word xx.x Object Library
Dim wordApp As Word.Application
Dim wordDoc As Word.Document

Set wordApp = CreateObject("Word.Application")
wordApp.Visible = True
Set wordDoc = wordApp.Documents.Open("C:\Documents and Settings\michel\test.doc")

With wordDoc.Content.Find
.ClearFormatting
.Text = "Insert_communes"
With .Replacement
.ClearFormatting
.Text = "ville"
End With
.Execute Replace:=wdReplaceAll
.Forward = True
.Wrap = wdFindContinue
End With

End Sub


j'espere que cela pourra t'aider

bonne soiree
MichelXld