Article ID: 183647
Article Last Modified on 6/17/2005
Sub MacroPauseExample()
Dim mykey as Variant
'Set the Normal.dot to hold keyboard changes.
CustomizationContext = NormalTemplate
' Determine Pause State by looking at the
' specified key combination command assignment.
Set mykey = KeyBindings.Key(BuildKeyCode _
(wdKeyControl, wdKeyAlt, wdKeyA))
' If there is no Command assignment(meaning
' the macro is not in a paused state.)
If (mykey Is Nothing) Then
' ------------------------------------------------------
' <Place your code to run, BEFORE the pause occurs, here.>
' ------------------------------------------------------
' Pause the macro.
KeyBindings.Add KeyCode:=BuildKeyCode _
(wdKeyControl, wdKeyAlt, wdKeyA), _
KeyCategory:=wdKeyCategoryMacro, _
Command:="MacroPauseExample"
Exit Sub
Else ' The macro has been paused. Clear the pause state.
' Sets the Normal.dot to hold keyboard changes.
CustomizationContext = NormalTemplate
' Clear Pause State.(Clear the command associated
' with the specified key combination.)
FindKey(BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyA)).Disable
End If
' ------------------------------------------------------------
' <Place your code to run, AFTER the pause is complete, here.>
' ------------------------------------------------------------
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbhowto kbmacroexample KB183647