Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 07-05-2024, 05:17 AM
savvy savvy is offline toggle macros assigned to key in Word 365 Windows 11 toggle macros assigned to key in Word 365 Office 2019
Novice
toggle macros assigned to key in Word 365
 
Join Date: Aug 2020
Location: Toronto
Posts: 23
savvy is on a distinguished road
Default

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

Tags
disable macro, enable macro, toggle macro assignment



Similar Threads
Thread Thread Starter Forum Replies Last Post
toggle macros assigned to key in Word 365 Autosave toggle missing completely in Word 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
toggle macros assigned to key in Word 365 MERGESEQ does not appear to be having a value assigned 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft