setting broken underline

D

David Thielen

Hi;

Is there any way to set a broken underline (like the incorrect
spelling one) on a range?

And can it be set to be like a selection - as soon as the user moves
the caret, it goes away?

thanks - dave
 
J

Jezebel

David Thielen said:
Hi;

Is there any way to set a broken underline (like the incorrect
spelling one) on a range?

Yes. Format > Font : Select the underline style
And can it be set to be like a selection - as soon as the user moves
the caret, it goes away?

No.
 
D

David Thielen

That makes sense (I can't believe I didn't look).

Ok, if I want to make the underline temporary, what events do I need
to watch to turn it off? The ones I can think of are:
selection change
typing/deleting text (is there an event for that?)
saving the document
a replace is occuring (is there an event for that?)

??? - thanks - dave
 
J

Jezebel

There's no easy way to do this. SelectionChange is not fired if the user
moves away from the selected range by entering text or using the arrows
keys. There is no KeyPress event or similar, nor is there a Replace event.

You could use a timer and check every few seconds to see if the selection is
still within the underlined range and switch it off if not; but you're
really getting outside the sorts of actions for which VBA is intended. In
practice this kind of programming tends to render Word user-unfriendly. What
are you actually trying to achieve?
 
J

Jonathan West

David Thielen said:
That makes sense (I can't believe I didn't look).

Ok, if I want to make the underline temporary, what events do I need
to watch to turn it off? The ones I can think of are:
selection change
typing/deleting text (is there an event for that?)

Yes, you need to use the WindowSelectionChange event of the application
object. For writing application event procedures in Word VBA, take a look at
this article

Writing application event procedures
http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm
saving the document

The DocumentBeforeSave event
a replace is occuring (is there an event for that?)

There is no event directly for that, but you can write a macro that
intercepts any built-in command. All you need to do is give the macro the
same name - in this case EditReplace.
 
D

David Thielen

You've convinced me - I'm not going to do it. I'll just select the
range.

thanks - dave
 

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