a bug in Word's Underline, Italic and Bold commands

L

Larry

I've found an odd defect in Word's Underline command in Word 97, as
well as in the Bold command and the Italic command.

If you have an underlined word immediately followed by a close quote or
punctuation, and if you locate the cursor just before the last character
of the word and run Underline command, the Underline command will not
work to remove the Underline formatting from the word. If the word is
not underlined, the Underline command will work correctly from that
position to underline the word. It's only with the removal of
Underlining that the command will not work from that cursor position.

Now get this. If you create a macro based on the Underline command and
run that macro in the same circumstance (punctuation or close quote
immediately following the word, with the word underlined, and the cursor
just before the last character of the word), the macro will work
properly to remove the underlining from the word.

This is not only strange in itself, but it's also an exception from the
situation you often run into, that a macro based on a built-in command
will lose some functionality that the command had. But in this case,
the macro has _more_ functionality than the built-in command!

Larry
 
W

Word Heretic

G'day "Larry" <[email protected]>,

The Selection object is a law unto itself and does 'silly' things as
per many user settings and hard coded responses.


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Larry reckoned:
 
K

Klaus Linke

Hi Larry,

The built-in command ("WordBasic.Underline") acts exactly the same when run
in a macro as when clicking the toolbar button when I try.
What macro/code did you use?

BTW, "Tools > Options > Edit > When selecting, automatically select entire
word" has to be checked, else Word will never underline anything if you
have nothing selected.

I usually have it unchecked.

The reason why it doesn't remove the underline when you're right between a
word and a quote is probably that Word can't figure out what "word" you
mean. If you are to the right of a word, clicking the U button will do
nothing, either.

Regards,
Klaus
 
L

Larry

Hi Klaus,

The problem is not that the command does not remove underlining from the
word when the cursor is BETWEEN the word and a close punctuation.
That's an understandable limitation on the command. The problem is that
it does not remove underlining when there is close punctuation after the
word, AND the cursor is between the second-to-last letter of the word
and the last letter. This is a tiny bug, but it is a bug and it is
curious.

You confuse me when you say the command name is WordBasic.Underline
because I'm thinking that's the command in Word 6 which may be different
from the command in Word 97.
When I turn the Underline command into a macro, this is the code. This
macro does not have the bug. The built-in command does.

If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If

Larry
 
K

Klaus Linke

Hi Larry,
The problem is that it does not remove underlining when there
is close punctuation after the word, AND the cursor is between
the second-to-last letter of the word and the last letter.

Ah, didn't read that carefully enough.
Still can't repro in Word 6 or Word 2000/2002/2003, though.
It might be some setting or other that is different on my machines, or
perhaps some bug that's special to Word97.

You confuse me when you say the command name is WordBasic.Underline

In Word 6/WordBasic, what Word did when you ran some command from the user
interface (by clicking some button) and from a macro were the same.

Though WordBasic as a macro language is dead, just about all the built-in
commands (even the new ones in Word2003) still "belong" to the WordBasic
object.


I don't know whether you wrote your macro by hand, or used the macro
recorder.

But even if the macro recorder produces some VBA code, it's really
translating built-in commands to VBA.
In many cases, it doesn't even try, and gives you the WordBasic command, or
nothing at all.

Because recording is not trivial (as it used to be in Word 6), the
"recorded" (= translated) VBA code often is rather clumsy, or doesn't act
quite the same as what was done in the user interface when recording the
macro.


Greetings,
Klaus
 

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