View Single Post
 
Old 06-29-2024, 09:12 AM
savvy savvy is offline Windows 11 Office 2019
Novice
 
Join Date: Aug 2020
Location: Toronto
Posts: 23
savvy is on a distinguished road
Default

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
Reply With Quote