30ai.dotm text is:
[1] text [2] text []
[3] text d [Monday] text add
[1] asdfasd [asadfasdf]
The code is
Option Explicit
Sub RevertEndKey()
On Error Resume Next
Application.KeyBindings.Clear keyCode:=BuildKeyCode(wdKeyEnd)
On Error GoTo 0
End Sub
Sub AssignEndKey()
On Error Resume Next
Application.KeyBindings.Add keyCode:=BuildKeyCode(wdKeyEnd), _
keyCategory:=wdKeyCategoryMacro, Command:="SelNext"
On Error GoTo 0
End Sub
Sub CreateRevertHotkey()
On Error Resume Next
Application.KeyBindings.Add keyCode:=BuildKeyCode(wdKeyShift, wdKeyControl, wdKeyF8), _
keyCategory:=wdKeyCategoryMacro, Command:="RevertEndKey"
On Error GoTo 0
End Sub
Sub CreateAssignHotkey()
On Error Resume Next
Application.KeyBindings.Add keyCode:=BuildKeyCode(wdKeyShift, wdKeyControl, wdKeyF9), _
keyCategory:=wdKeyCategoryMacro, Command:="AssignEndKey"
On Error GoTo 0
End Sub
Sub SelNext()
On Error GoTo ErrHandler
Dim findText As String
findText = "\[*\]"
With Selection.Find
.Text = findText
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
If Selection.Find.Found Then
' Do nothing, found and selected text
Else
' Do nothing, no text found
End If
Exit Sub
ErrHandler:
' Handle error silently
End Sub
cannot get the assigned key to revert, my coding is limited and chatgpt is useless
any suggestions appreciated
|