Hi,
This week I fixed my changes from the previous week, I also looked at the XFind method on writer and wrote macro tests in word to test find and replace.
Struggled for a while before finding this :
Selection seemed to be a problem to start with and the test will not work without A.
Also seemed like the 'with' is broken and creates new find objects - B
Selection.TypeText Text:="testing number two"
' without this it doesn't work ...
A . ActiveDocument.Content.Select
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
' without this it doesn't work ...
A . ActiveDocument.Content.Select
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
B.
+ let f = Selection.Find
+ With f ' works
- With Selection.Find ' breaks things.
.Text = "t"
.Replacement.Text = "l"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
+ With f ' works
- With Selection.Find ' breaks things.
.Text = "t"
.Replacement.Text = "l"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Looks like this could be due to code in sw/source/ui/vba/vbaselection.cxx getFind
which I will aim to look at next week