Consulting

Results 1 to 4 of 4

Thread: Can't associate a keystroke with my MarkupToggle macro

  1. #1
    VBAX Newbie
    Joined
    Jan 2017
    Posts
    3
    Location

    Question Can't associate a keystroke with my MarkupToggle macro

    I've written the following Macro and put it in my Normal Module1 (and tried it in my Normal ThisDocument)

    Sub MarkupToggle() ' MarkupToggle Macro
    'MsgBox "MarkupToggle called"
    With ActiveWindow.View
    .ShowRevisionsAndComments = Not .ShowRevisionsAndComments
    .RevisionsView = wdRevisionsViewFinal
    End With
    End Sub

    I've tried assigning a keystroke to the macro:


    With Application
    .CustomizationContext = NormalTemplate
    With .KeyBindings
    .Add KeyCode:=BuildKeyCode(Arg1:=wdKeyAlt, Arg2:=wdKeyM), KeyCategory:=wdKeyCategoryCommand, Command:="MarkupToggle"
    .Add KeyCode:=BuildKeyCode(Arg1:=wdKeyCommand, Arg2:=wdKeyG), KeyCategory:=wdKeyCategoryCommand, Command:="SaveTextForGit"
    End With
    End With

    But pressing Alt+M doesn't run the macro.
    Many other macros that I've created work fine with similar keystrokes.
    What could be wrong?

  2. #2
    VBAX Newbie
    Joined
    Mar 2017
    Location
    Los Angeles area
    Posts
    1
    Location

    Figured out?

    Wow--I have exactly the same problem! Did you figure this out??? My macro is exactly the same as yours (without the MsgBox() call, and I use Alt+S for the keyboard shortcut, which I assign in the GUI). It used to work, too! Don't know what changed--an update to Word maybe? (Word 2007 on a PC with Windows 7 Ultimate, in my case.) What I can say is that:
    • Changing the name of the macro to MarkupTogglex (or likely anything else, I suspect) makes it work.
    • "MarkupToggle" is not in the registry, so that's not it.
    • Stripped it down to this being the only assignment in the default Normal.dotm (also did Reset All in the GUI Customize Keyboard dialog. At that point, KeyBindings(1).KeyString is "Alt+S" as expected, but KeyBindings(1).Command is empty--which is why nothing runs.
    • But If I change the macro name to MarkupTogglex and reassign that to Alt+S, then KeyBindings(1).Command is Normal.NewMacros.MarkupTogglex as expected.


    Very strange!

    Quote Originally Posted by bburd View Post
    I've written the following Macro and put it in my Normal Module1 (and tried it in my Normal ThisDocument)

    Sub MarkupToggle() ' MarkupToggle Macro
    'MsgBox "MarkupToggle called"
    With ActiveWindow.View
    .ShowRevisionsAndComments = Not .ShowRevisionsAndComments
    .RevisionsView = wdRevisionsViewFinal
    End With
    End Sub

    I've tried assigning a keystroke to the macro:


    With Application
    .CustomizationContext = NormalTemplate
    With .KeyBindings
    .Add KeyCode:=BuildKeyCode(Arg1:=wdKeyAlt, Arg2:=wdKeyM), KeyCategory:=wdKeyCategoryCommand, Command:="MarkupToggle"
    .Add KeyCode:=BuildKeyCode(Arg1:=wdKeyCommand, Arg2:=wdKeyG), KeyCategory:=wdKeyCategoryCommand, Command:="SaveTextForGit"
    End With
    End With

    But pressing Alt+M doesn't run the macro.
    Many other macros that I've created work fine with similar keystrokes.
    What could be wrong?

  3. #3
    VBAX Newbie
    Joined
    Jan 2017
    Posts
    3
    Location
    I haven't found any other information. Thanks for the suggestion about changing the name. I'll try that.

    Quote Originally Posted by rhoffman View Post
    • Changing the name of the macro to MarkupTogglex (or likely anything else, I suspect) makes it work.

  4. #4
    VBAX Newbie
    Joined
    Jan 2017
    Posts
    3
    Location
    Changing the name to MarkupTogglex fixed the problem. Thanks.

Tags for this Thread

Posting Permissions

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