![]() |
|
#1
|
|||
|
|||
![]()
Thank you so much. I am encountering errors beyond my scope.
Do you contract your time? If yes, what is your rate. Can I email you my mt.dotm, code, and objectives. If not, do you know someone who does? This is my code so far: "'--------------------------------------------- '1 1 1 1 ' Error handling and logging subroutine Sub LogError(errorMessage As String, lineNumber As Integer) Debug.Print "Error " & lineNumber & ": " & errorMessage End Sub '--------------------------------------------- '2 2 2 2 ' Subroutine to clear existing key binding for Ctrl+Shift+End if it exists Sub ClearExistingKeyBinding() On Error Resume Next Application.KeyBindings.Item(BuildKeyCode(wdKeyCon trol, wdKeyShift, wdKeyEnd)).Clear On Error GoTo 0 End Sub '--------------------------------------------- '3 3 3 3 ' Subroutine to add a new key binding for Ctrl+Shift+End Sub AddKeyBinding() On Error Resume Next With Application .CustomizationContext = ThisDocument ' Clear existing key binding (if necessary) ClearExistingKeyBinding ' Attempt to add key binding for Ctrl+Shift+End .KeyBindings.Add keyCode:=BuildKeyCode(wdKeyControl, wdKeyShift, wdKeyEnd), _ keyCategory:=wdKeyCategoryCommand, _ Command:="EndKeybinding" ' Check if an error occurred If Err.Number <> 0 Then ' Log the error LogError "Error adding key binding: " & Err.Description, 2 Err.Clear Else ' Key binding added successfully Debug.Print "Key binding added: Ctrl+Shift+End" End If End With On Error GoTo 0 End Sub '--------------------------------------------- '4 4 4 4 ' Function to build key codes for various combinations Function BuildKeyCode(ParamArray Keys() As Variant) As Long Dim key As Variant For Each key In Keys BuildKeyCode = BuildKeyCode + key Next key End Function '--------------------------------------------- '5 5 5 5 ' Test sub for key binding Sub TestKeybinding() MsgBox "TestKeybinding activated!", vbInformation, "Key Binding Test" End Sub '--------------------------------------------- '6 6 6 6 ' Subroutine to enumerate and list available key bindings Sub ListAvailableKeyBindings() Debug.Print "Starting ListAvailableKeyBindings" Dim aKB As KeyBinding CustomizationContext = ThisDocument ' Loop through each key binding and print details For Each aKB In KeyBindings Debug.Print "Key String: " & aKB.keyString Debug.Print "Command: " & aKB.Command Debug.Print "---" Next aKB Debug.Print "Ending ListAvailableKeyBindings" End Sub '--------------------------------------------- '6 6 6 6 " I want to reassign the numeric pad keys to run simple macros in mt.dotm. However, if I need to manually edit, I need a hot key ex: shft ctl f11 to toggle the numeric pad keys to default word actions and then back. This master template 'mt' will be adapted to create docx for different scenarios, all needing the toggling of the numeric keys functions. I use office 365 and can code a bit with ahk, macroexpress3, and vbs. Appreciatively Mike |
![]() |
Tags |
disable macro, enable macro, toggle macro assignment |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
MikeyLasco77 | Word | 6 | 03-02-2023 07:08 AM |
Word Refuses to Allow Macros, even when All Macros Enabled | devlon | Word VBA | 3 | 10-04-2022 02:15 PM |
![]() |
gjone43 | Mail Merge | 6 | 10-15-2020 08:15 PM |
vba editor - how to toggle the continuous display of all macros in a module | floattube | Word VBA | 0 | 11-28-2014 01:35 PM |
Is there a way to toggle the contents that are displayed in a Word document? | sclind | Word | 1 | 02-24-2012 04:56 PM |