Consulting

Results 1 to 9 of 9

Thread: Intercept highlight command

  1. #1

    Intercept highlight command

    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.

  2. #2
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    AFAIK that's not one you can intercept. See: http://word.mvps.org/FAQs/General/CommandsList.htm
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    If I write:

    Sub Highlight()
    MsgBox "Yadda"
    End Sub
    when I click the Highlight button I get the messagebox.

  4. #4
    Quote Originally Posted by macropod View Post
    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.

  5. #5
    Quote Originally Posted by fumei View Post
    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?

  6. #6
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,351
    Location
    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 ;-)
    Greg

    Visit my website: http://gregmaxey.com

  7. #7
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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.

  8. #8
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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.

  9. #9
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •