E
Ed
Running a macro that has run fine on a new document, it now throws an error.
The code is supposed to find some text, then capture the text immediately
following.
rngDoc2.Find.Execute FindText:="| 4. L5-"
rngDoc2.MoveEnd Unit:=wdWord, Count:=1
strDoc = rngDoc2.Text
For some reason, when the FindText was not there before, the macro would
end. Now, though, it gives me a paragraph mark as the string contents,
which screws up the rest of the macro (it wants to ceate a file name using
this string).
As this is in a Do loop, is it best to
If Not rngDoc2.Find.Execute FindText:="| 4. L5-" Then Exit Do
as a way to break out of the loop if the text isn't found, but continue if
it is? Is there a better way?
Ed
The code is supposed to find some text, then capture the text immediately
following.
rngDoc2.Find.Execute FindText:="| 4. L5-"
rngDoc2.MoveEnd Unit:=wdWord, Count:=1
strDoc = rngDoc2.Text
For some reason, when the FindText was not there before, the macro would
end. Now, though, it gives me a paragraph mark as the string contents,
which screws up the rest of the macro (it wants to ceate a file name using
this string).
As this is in a Do loop, is it best to
If Not rngDoc2.Find.Execute FindText:="| 4. L5-" Then Exit Do
as a way to break out of the loop if the text isn't found, but continue if
it is? Is there a better way?
Ed