Need help creating shortcut keys to add-in macros

mbrittb

Board Regular
Joined
Jul 24, 2002
Messages
62
I am trying to convert the macros from one of my spreadsheets into an add-in. The only problem that I am running into is there are a couple of my functions that I frequently access via shortcut/accelerator keys (i.e. ctrl-s, NOT save). Is there anyway I can set up the add-in so that I can still use these shortcut/accelerator keys. Please let me know what code I need to add and where I need to add it.

Thanks,

Britt
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I checked out the link from your response. Unfortunatlly it did not answer my problem. I am trying to create a shortcut key definition (similar to ctrl-s for saving) to activate a particular macro in my addin. Maybe I missed it, but that linkdidn't have anything along those lines.
 
Upvote 0
Ok,
1) where do I need to put those functions? ThisWorkbook?

2) do you have a list of how to define the keys, or combinations of them. i.e. page down is specified by the code PgDn. What would say Control-s, or Control-w be.

Thanks,

Britt
 
Upvote 0
I would put then in the Workbook_Open event (or in a macro that is called via the Workbook_Open event

The code would look like this:

Application.OnKey "^s" "MyMacroName"


you may also want toreturn the Ctrl+S shortcut to it's default in the Workbook_Close event with a line like this:

Application.OnKey "^s"
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top