Find text and determine page

N

nnn

I've found all kinds of messages that say this should work:

Selection.Find.ClearFormatting
With Selection.Find
.Text = "SomeUniqueValue"
End With
Selection.Find.Execute
i = selection.Information(wdActiveEndPageNumber)

i should be page 3 if SomeUniqueValue is found on page 3. But I don't
get results like this. i is usually the wrong page, and when I check the
value of selection.text, it's one of those charming square characters.

I need to run a couple of searches for text in a row, and determine the
page number each 'find' was on. No matter what order I run the test in,
results are off. This should be so simple...
 
N

nnn

I've found all kinds of messages that say this should work:

Selection.Find.ClearFormatting
With Selection.Find
.Text = "SomeUniqueValue"
End With
Selection.Find.Execute
i = selection.Information(wdActiveEndPageNumber)

i should be page 3 if SomeUniqueValue is found on page 3. But I don't
get results like this. i is usually the wrong page, and when I check the
value of selection.text, it's one of those charming square characters.

I need to run a couple of searches for text in a row, and determine the
page number each 'find' was on. No matter what order I run the test in,
results are off. This should be so simple...
Got it working, using code like the above, my mistake.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top