PDA

View Full Version : Can't associate a keystroke with my MarkupToggle macro



bburd
01-21-2017, 01:45 PM
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?

rhoffman
03-23-2017, 05:28 PM
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!


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?

bburd
03-23-2017, 07:04 PM
I haven't found any other information. Thanks for the suggestion about changing the name. I'll try that.




Changing the name of the macro to MarkupTogglex (or likely anything else, I suspect) makes it work.

bburd
03-23-2017, 07:09 PM
Changing the name to MarkupTogglex fixed the problem. Thanks.