Article ID: 159484
Article Last Modified on 1/19/2007
173707 OFF97: How to Run Sample Code from Knowledge Base Articles
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)).Clear
End If
' ------------------------------------------------------------
' <Place your code to run, AFTER the pause is complete, here.>
' ------------------------------------------------------------
End Sub
For additional information about available resources for creating custom solutions using Visual Basic for Applications and Microsoft Word 97, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
163425 WD97: Macro Programming Resources
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe halt stop paused pausing halting stopping
Keywords: kbdtacode kbhowto kbmacroexample kbusage KB159484