Macro VBA - Ouvrir un doc Word depuis Excel puis chercher un mot spécifique
Bonjour,
Je cherche à ouvrir un doc word depuis excel, puis rechercher un mot défini à l'avance.
Pour ouvrir le doc, j'ai une macro excel qui fonctionne :
Code:
1 2 3
| Sub Ouvrir_Document()
ThisWorkbook.FollowHyperlink "\\aaa\dossier\fichier.doc"
End Sub |
Pour sélectionner un mot, j'en ai une autre qu
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Sub Chercher_mot()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "mot"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub |
Par contre, je n'arrive pas à lier les deux macros (ouvrir le doc depuis excel, puis chercher le mot spécifique". Un message d'erreur me demande un objet...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Sub Ouvrir_Document_Chercher_mot()
ThisWorkbook.FollowHyperlink "\\aaa\dossier\fichier.doc"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "mot"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub |
Quelqu'un aurait la solution ? Merci d'avance !
Roland