[VBA] Problème avec replacement
Le
HD
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
--
@+
HD
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
--
@+
HD

Poser une question


Bonsoir,
Voulez-vous essayer ceci, une autre manière de faire ?
'adapter le code svp et définir les variables
Pos1 = Selection.End
Selection.MoveDown Unit:=wdLine, Count:=xxxx, Extend:=wdMove
PosDep1 = Selection.End
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