O
OughtFour
I'm failing to get this statement
Do While .Execute(Replace:=wdReplaceAll)
loop
to run until there is nothing left to replace. (More complete example below,
but this is the crux of the matter.)
I've tried using .Found for the same purpose. It always evaluates as false,
even though the macro makes the replacement in the document.
The problem exists in Office 97 and also in Office v.X, which use more or
less the same version of vba.
Now I've googled the usenet archives and found several examples of people
enthusiastically recommending this kind of loop. None describing any
problems doing so.
So it seems likely that I'm just making some hideously stupid mistake. But,
I give up. Can anyone tell me what the mistake is?
More-complete example--
Sub Despacify()
With ActiveDocument.Content.Find
.Wrap = wdFindContinue
.Forward = True
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
'read away extra spaces
.Text = " ^p"
.Replacement.Text = "^p"
Do While .Execute(Replace:=wdReplaceAll)
Loop
End With
End Sub
By the way: I can't use a wildcard search for this purpose because I am
developing for both Windows and OS X. Office for X does not support many
wildcard searches.
Thanks for any advice!
Do While .Execute(Replace:=wdReplaceAll)
loop
to run until there is nothing left to replace. (More complete example below,
but this is the crux of the matter.)
I've tried using .Found for the same purpose. It always evaluates as false,
even though the macro makes the replacement in the document.
The problem exists in Office 97 and also in Office v.X, which use more or
less the same version of vba.
Now I've googled the usenet archives and found several examples of people
enthusiastically recommending this kind of loop. None describing any
problems doing so.
So it seems likely that I'm just making some hideously stupid mistake. But,
I give up. Can anyone tell me what the mistake is?
More-complete example--
Sub Despacify()
With ActiveDocument.Content.Find
.Wrap = wdFindContinue
.Forward = True
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
'read away extra spaces
.Text = " ^p"
.Replacement.Text = "^p"
Do While .Execute(Replace:=wdReplaceAll)
Loop
End With
End Sub
By the way: I can't use a wildcard search for this purpose because I am
developing for both Windows and OS X. Office for X does not support many
wildcard searches.
Thanks for any advice!