PDA

View Full Version : Intercept highlight command



leprendun
10-08-2013, 01:28 AM
I wrote a macro that is supposed to intercept the Word highlight command and stop highlighting from being tracked--it basically turns off revision tracking when the highlight button is pressed, and then turns it back on again after the text is highlighted. I've intercepted commands before and it has been fairly simple, yet I can't get this one to work. I've tried Sub Highlight(), which is given in the Command list, but also Sub HighlightColorPicker() and Sub TextHighlightColorPicker(), all with no luck. The macro does work correctly when run from VBA, it's just not called from the highlight button. Any ideas? Thanks for your help.

macropod
10-14-2013, 03:51 AM
AFAIK that's not one you can intercept. See: http://word.mvps.org/FAQs/General/CommandsList.htm

fumei
10-14-2013, 11:34 AM
If I write:


Sub Highlight()
MsgBox "Yadda"
End Sub

when I click the Highlight button I get the messagebox.

leprendun
10-14-2013, 01:52 PM
AFAIK that's not one you can intercept.

I think that list is outdated. I used VBA's listcommands method to return all the Word commands and Highlight was on there.

leprendun
10-14-2013, 01:54 PM
If I write:


Sub Highlight()
MsgBox "Yadda"
End Sub

when I click the Highlight button I get the messagebox.

That's so strange! What version of Word are you using? I copied your code exactly and tried it out with no success on my end. Oddly enough, I have noticed that the intercepted highlight command works when using the highlight keyboard shortcut, but not the actual highlight button. Maybe the highlight button uses a different command than the shortcut?

gmaxey
10-14-2013, 03:05 PM
He is using Word 2003 and if I know fumei then he is snickering about what he can do with Word 2003 that we can't do with Word 2007, 2010 and 2013 ;-)

fumei
10-14-2013, 11:21 PM
No, not really. I was just stating a fact. I am a bit - seriously - curious as to why it is not working fpr later versions.

As for keyboard shortcut VS. button, it is difficult to say because shortcuts can of course be mapped to anything. OK, I played with 2010 trying to get Highlight to be overridden. Mmmmm, it is possible that Paul (macropod) is correct. Highlight can not be overriden. Stupid Microsoft. More of the I-know-better-than-you, and you can not be trusted attitude. Why on earth would they do that. Stupid.

fumei
10-14-2013, 11:38 PM
I am finding this extremely annoying... Ticked off actually. Tried possible names (HighlightText, TextHighlight etc). No luck. Shrug, I guess it really is not allowed. Stupid Microsoft.

leprendun
10-15-2013, 05:24 AM
I am also ticked off! I have been stewing over this problem for 2 weeks now, and while it's not an essential function, it's more the principal of the matter. The highlight button is called from the TextHighlightColorPicker control on the ribbon; it's a splitbutton, containing both the highlight button and a drop-down menu with all the highlight colors. I imagine the Ctrl+D shortcut calls the normal highlight function, but the button itself calls some other function to process the splitbutton. If you think of anything, let me know!