Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-25-2020, 01:43 AM
alex100 alex100 is offline Assigning shortcut keys via a macro file Windows 7 64bit Assigning shortcut keys via a macro file Office 2016
Advanced Beginner
Assigning shortcut keys via a macro file
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default Assigning shortcut keys via a macro file

How do I assign a shortcut key to a MS Word subroutine?

I already know how to do it via the "Customize Ribbon" Options menu, but I'm interested in hardcoding the keys inside a macro file.

I understand I need to use something like the code below, but where exactly do I insert this code? I tried adding it to the 'ThisDocument' section, without any success.

Code:
With Application
    .CustomizationContext = ThisDocument
    .KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF1), _
    KeyCategory:=wdKeyCategoryCommand, _
    Command:="printAllRecords"
End With
source: VBA Word: how to call a function via shortcut key?

As an example, what I need is to call "MyScript1" subroutine when pressing Ctrl + L, and "MyScript2" subroutine when pressing Alt + L.

Alex
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
macro used to activate shortcut keys hudsontucker13 PowerPoint 1 12-14-2013 09:47 AM
Assigning shortcut keys via a macro file Word VBA: assign shortcut keys to sub??? tinfanide Word VBA 2 12-05-2011 03:41 AM
Outlook Mail Shortcut Keys? gratiot Outlook 3 07-29-2011 10:31 AM
cant use shortcut keys (ctrl+c/v/z...) laro Office 0 10-08-2010 11:01 PM
Can't Assign Shortcut Keys Vicki F. Word 0 04-17-2010 03:03 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:28 AM.


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