"Find" problem

V

Vivian Carroll

In a Word 2000 template, I have a macro button that deletes the selected
paragraph and then runs the following procedure to find the @ symbol. In
Word 2000, when this macro button is in the last paragraph of the document,
the paragraph gets deleted and the cursor stays at the end of the document
because there are no @ symbols after it. It does not ask the user whether to
continue searching at the beginning. This is what I want.

With Selection.Find
.ClearFormatting
.Text = "@"
.Forward = True
.Wrap = wdFindAsk
.Execute
End With

However, in Word 2002, when I click the macro button, the cursor cycles up
to the top of the document and selects the first @ symbol it finds. I
thought that ".wrap = wdFindAsk" would at least make it ask the user whether
to go to the top of the document but it doesn't.

QUESTION: In Word 2002, how do I make it stop at the end of the document if
it does not find an @ symbol (and not ask the user whether to start at the
beginning)?

TIA,
Vivian
 
V

Vivian Carroll

Sorry, that was a dumb question - guess I was too close to it. While I was
eating lunch and not thinking about Word (ha, ha), I realized that all I had
to do was change .Wrap=wdFindAsk to .Wrap=False.
 
K

Klaus Linke

I realized that all I had to do was change .Wrap=wdFindAsk to .Wrap=False.


Hi Vivian,

I'd rather use .Wrap=wdFindStop.

It's the same to the VBA interpreter, since both constants are = 0.
But wdFindStop is the "proper" constant, and easier to understand for a
human.

;-) Klaus
 
V

Vivian Carroll

Thanks Klaus. Where can I find a listing of constants (they don't appear as
a screen tip when typing in VBA and I can't find them in Help)?
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Vivian,

In the VBE, type wrap and then press F1 to bring up the help on the Wrap
property and then click on the wdFindWrap link to see the constants.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
V

Vivian Carroll

Thanks Doug,

It was clicking on the wdFindWrap link that I missed.

Vivian

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
 

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