|
Visual Basic (VB6 and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Visual Basic Library
This page was last updated on Saturday, November 24, 2001
Public Function AssignKey(strMacro As String, lngKey As Long) ' Procedure : AssignKey ' Description: Assign a user macro to a key. ' Copyright: Chris Greaves Inc. ' Inputs: STRING name of a user macro. ' Returns: None. ' Assumes: None. ' Side Effects: Key assignments will change. ' Tested: By the calls shown below. ' The little subroutines Test1 and Test2 demonstrate that they have run by displaying a msgBox. ' The TESTAssignkey procedure assigns each of the two macros to function keys. ' Run the TESTAssignkey macro, then switch (Alt-Tab) to Word and ' try tapping the F4 and F5 function keys. ' The key assignments will last until re-assigned or until Word97 is reloaded. KeyBindings.Add KeyCode:=BuildKeyCode(lngKey), KeyCategory:=wdKeyCategoryMacro, Command:=strMacro 'Sub TEST1() 'MsgBox "one" 'End Sub 'Sub TEST2() 'MsgBox "two" 'End Sub 'Sub TESTAssignKey() ' Call AssignKey("TEST1", wdKeyF4) ' assign the
key to the macro TEST1 ' Call AssignKey("TEST2", wdKeyF5) ' assign the key to the macro TEST2 'End Sub End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Monday, November 19, 2001 |