Different results from style macro and a QAT button to the same macro

Joined
Oct 28, 2024
Messages
1
Reaction score
0
I am intrigued and confused by a strange activity from styles and macros!
I have a style that sets the font to Courier New and is defined as below.
Its main use is formatting copied macros from various web sources, into a word document
Style definition:
Font: (Default) Courier New, Do not check spelling or grammar, English (United States), Style: Linked, Show in the Styles gallery, Priority: 10
Based on: Normal ,Following style: Normal

I have a macro to set the selected text to this style:

Sub MyTextStyle() 'set text to Courier New 12pt
'QAT icon as amber square

Selection.Style = ActiveDocument.Styles("No Spacing,My Text")
End Sub

I also have made this macro available from my QAT.

The issue I have is this:
If I copy/paste from the web, and use the Style Gallery to set the format, I usually have to run it twice – first run sets the font but still underlines spelling errors, second run clears the spelling errors.
When I use the QAT icon it will set the font but even running a second or third time it never clears the spell-checking underlines. (Using the style gallery here will clear spelling).

Why does this happen, and how do I overcome it?
Not a big deal but it would be much more convenient to use the icon and have the magic happen with one click.

Any help is much appreciated. and thanks in anticipation.

Beepee
 
Top