J'ai un petit souci avec ma macro VBA... Le texte recherché est bien trouvé,
il est sélectionné mais par contre il n'est pas remplacé par mon texte de
remplacement... Avez vous une idée de ce qui pourrait coincé ?
Vous en remerciant d'avance.
Voici mon code :
Dim AppWord As Object, DocWord As Object
Set AppWord = CreateObject("Word.Application")
AppWord.ShowMe
AppWord.Visible = True
Set DocWord = AppWord.Documents.Open(CheminW, ReadOnly:=False)
With AppWord.Selection
.wholestory
.Find.ClearFormatting
.Find.Replacement.ClearFormatting
With .Find
.Text = "[PRODVEGER]"
.Replacement.Text = "TTTTESSTTTTTTTTTT"
.Forward = True
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Wrap = wdFindContinue
End With
.Find.Execute Replace:=wdReplaceAll
End With
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Gérard GODIN
Le 19/04/2011 14:07, HD a écrit :
Bonjour,
J'ai un petit souci avec ma macro VBA... Le texte recherché est bien trouvé, il est sélectionné mais par contre il n'est pas remplacé par mon texte de remplacement... Avez vous une idée de ce qui pourrait coincé ? Vous en remerciant d'avance. Voici mon code :
Dim AppWord As Object, DocWord As Object Set AppWord = CreateObject("Word.Application") AppWord.ShowMe AppWord.Visible = True Set DocWord = AppWord.Documents.Open(CheminW, ReadOnly:úlse)
With AppWord.Selection .wholestory .Find.ClearFormatting .Find.Replacement.ClearFormatting With .Find .Text = "[PRODVEGER]" .Replacement.Text = "TTTTESSTTTTTTTTTT" .Forward = True .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Wrap = wdFindContinue End With .Find.Execute Replace:=wdReplaceAll End With
Bonsoir,
Voulez-vous essayer ceci, une autre manière de faire ? 'adapter le code svp et définir les variables
Set maselection = ActiveDocument.Range(Start:=Pos1, End:=PosDep1) With maselection.Find .ClearFormatting .Text = "." With .Replacement .ClearFormatting .Text = "," End With .Execute Replace:=wdReplaceAll, _ Format:=True, MatchCase:=True, _ MatchWholeWord:=True End With
End Sub
Bonne soirée
Le 19/04/2011 14:07, HD a écrit :
Bonjour,
J'ai un petit souci avec ma macro VBA... Le texte recherché est bien trouvé,
il est sélectionné mais par contre il n'est pas remplacé par mon texte de
remplacement... Avez vous une idée de ce qui pourrait coincé ?
Vous en remerciant d'avance.
Voici mon code :
Dim AppWord As Object, DocWord As Object
Set AppWord = CreateObject("Word.Application")
AppWord.ShowMe
AppWord.Visible = True
Set DocWord = AppWord.Documents.Open(CheminW, ReadOnly:úlse)
With AppWord.Selection
.wholestory
.Find.ClearFormatting
.Find.Replacement.ClearFormatting
With .Find
.Text = "[PRODVEGER]"
.Replacement.Text = "TTTTESSTTTTTTTTTT"
.Forward = True
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Wrap = wdFindContinue
End With
.Find.Execute Replace:=wdReplaceAll
End With
Bonsoir,
Voulez-vous essayer ceci, une autre manière de faire ?
'adapter le code svp et définir les variables
Set maselection = ActiveDocument.Range(Start:=Pos1, End:=PosDep1)
With maselection.Find
.ClearFormatting
.Text = "."
With .Replacement
.ClearFormatting
.Text = ","
End With
.Execute Replace:=wdReplaceAll, _
Format:=True, MatchCase:=True, _
MatchWholeWord:=True
End With
J'ai un petit souci avec ma macro VBA... Le texte recherché est bien trouvé, il est sélectionné mais par contre il n'est pas remplacé par mon texte de remplacement... Avez vous une idée de ce qui pourrait coincé ? Vous en remerciant d'avance. Voici mon code :
Dim AppWord As Object, DocWord As Object Set AppWord = CreateObject("Word.Application") AppWord.ShowMe AppWord.Visible = True Set DocWord = AppWord.Documents.Open(CheminW, ReadOnly:úlse)
With AppWord.Selection .wholestory .Find.ClearFormatting .Find.Replacement.ClearFormatting With .Find .Text = "[PRODVEGER]" .Replacement.Text = "TTTTESSTTTTTTTTTT" .Forward = True .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Wrap = wdFindContinue End With .Find.Execute Replace:=wdReplaceAll End With
Bonsoir,
Voulez-vous essayer ceci, une autre manière de faire ? 'adapter le code svp et définir les variables
Set maselection = ActiveDocument.Range(Start:=Pos1, End:=PosDep1) With maselection.Find .ClearFormatting .Text = "." With .Replacement .ClearFormatting .Text = "," End With .Execute Replace:=wdReplaceAll, _ Format:=True, MatchCase:=True, _ MatchWholeWord:=True End With