
Create a macro in Outlook
You use Visual Basic for Applications (VBA) to create or edit macros in Outlook.
Create or edit a macro
To create or edit a macro by using Visual Basic for Applications (VBA), do the following:
On the Developer tab, choose Macros . See Show the Developer tab to learn how to display the Developer tab.
In the Macro dialog box, type a name for the macro.
Click Create to open Visual Basic for Applications (VBA).
Run a macro
For information about how to run a macro in Outlook, see Run a macro in Outlook .

Need more help?
Expand your skills.
EXPLORE TRAINING >
Get new features first
JOIN MICROSOFT 365 INSIDERS >
Was this information helpful?
Thank you for your feedback.
- https://www.yammer.com/
- http://feeds.feedburner.com/office/fmNx
This forum has migrated to Microsoft Q&A . Visit Microsoft Q&A to post new questions.
- Forums home
- Browse forums users
- Remove From My Forums
Answered by:
Assign keyboard shortcut to outlook vba macro.
I have tried adding the macro to a ribbon tab, and renaming the command using an Amperstand in front of the letter I want to access the macro with. However, the display of the command on the ribbon displays,
"Insert &Paragraph Symbol"
and the Alt+P does NOT call the macro. How can I make the Alt+P run the macro.
I've read how to use Alt+1, etc. to run macros on the Quick Access toolbar; however, I want to keep them consistent with the keystrokes I have assigned for Word.
Hi Orlandp,
Thank you for posting in the MSDN Forum.
Outlook does not support assigning shortcut to macro like Word does. The best approach I can think of is to add a command to Quick Access Toolbar and use Alt+(Number correspond to the command).
Since your issue is relate to the usage of Outlook, I suggest you repost it on the Outlook Answers Forum as well.
Hope it helps.
Best regards,
Quist Zhang [MSFT] MSDN Community Support | Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Edited by Quist Zhang Wednesday, February 20, 2013 8:58 AM
- Marked as answer by orlandp Thursday, February 21, 2013 3:50 PM
All replies
I tried using an Outlook macro similar to the one posted at http://stackoverflow.com/questions/9818047/excel-vba-assign-keyboard-shortcut-to-run-procedure which uses Application.OnKey but Outlook doesn't support the OnKey method. (My goal was ApplicationOnKey "+^v", "PasteUnformattedText: ' control shift v. ) and then run the macro when I start Outlook.
Perhaps because Word is used for editing a message I can wrap the above in the code that says to use Word's ability to assign keys to macros, but that is a bit beyond my Outlook coding at this time.
By the way, keyboard assignment stuff is described here: https://msdn.microsoft.com/en-us/library/office/ff197461.aspx?f=255&MSPPError=-2147217396
- Edited by PAReinie Wednesday, March 30, 2016 11:09 PM Add link to reference info
- O365 Technical Network
- MSDN Forums
- Stack Overflow
- Office Dev Blog
- Terms of Use
- Privacy Statement
Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Shortcut or macro for changing font type in Microsoft Outlook
Is there a keyboard shortcut for changing the font in Outlook on Windows? I have to alternate between Calibri and Courier constantly for technical reasons and clicking on the font dialog every time gets very tedious. I know that I can use Ctrl+Space to change anything to the default (Calibri) font.
If there is no shortcut, could someone please help me create a macro to toggle fonts? I imagine I can assign any shortcut to a macro?
- microsoft-outlook
- 2 You know, you can record macros in Word. – Oliver Salzburg Feb 21, 2013 at 18:59
2 Answers 2
(The answer by techie007 didn't work for me in Outlook 2010)
This macro (adapted from http://www.slipstick.com/developer/word-macro-apply-formatting-outlook-email/ ) does:
Next, in the VBA Editor go to Tools > References and select Microsoft Word 14.0 Object Library .
Now, to create a keyboard shortcut for a macro, add it to your Quick Access Toolbar as follows:
- Open a new mail message
- Click on the small drop down arrow on the Quick Access Toolbar (typically located at the top of the window) and select "More Commands..."

- The Outlook Options dialog will open, then select "Macros" from the "Choose commands from:" dropdown

- Select the SetCodeFont macro from the list and press "Add >>"
- The macro button will now appear on the Quick Access Toolbar
To run the macro highlight some text in your email, and press Alt + <Num> where <Num> is the position of the macro in your Quick Access Toolbar. For example, if the macro is the first button on the toolbar, use Alt + 1 to invoke it.
- Where do I find the VBE Editor? – Danijel Mar 23, 2017 at 14:33
- @Danijel To open the VBA editor, use the short cut Alt + F11. To paste the code above, please use the menu item Insert > Module . – Gogowitsch Sep 27, 2018 at 12:29
- Some users may need to select Microsoft Office 16.0 Object Library . – Irregardless Aug 27, 2020 at 19:49
Just FYI, this is the key sequence to focus the Font selector: Alt , H , F , F
- Alt+R doesn't work for me in Word or Outlook. Alt+H does though (Alt+H, F, F). Maybe a localization issue (since you're in Germany and I'm in the US)? – techturtle Feb 21, 2013 at 19:08
- @techturtle: I actually only use English software. Incidentally, I was working in a German VM at the time, so, yes, your analysis is correct :) – Oliver Salzburg Feb 21, 2013 at 19:12
- Much easier than a custom macro. If only I had an equivalent to BetterTouchTool on Windows, I'd be able to set this to an arbitrary keybinding directly. – Wildcard May 25, 2016 at 19:30
- @Wildcard you can use AutoHotkey to define a single hotkey that will send a different hotkey. E.g. ~^q::!hff means send Alt+H followed by f twice whenever Ctrl + Q is pressed. The tilde says AutoHotkey should allow the Ctrl + Q to be seen by any application. – Gogowitsch Sep 27, 2018 at 12:35
Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged microsoft-outlook macros or ask your own question .
- The Overflow Blog
- How Intuit democratizes AI development across teams through reusability sponsored post
- The nature of simulating nature: A Q&A with IBM Quantum researcher Dr. Jamie...
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
Hot Network Questions
- Is it possible to rotate a window 90 degrees if it has the same length and width?
- Why are physically impossible and logically impossible concepts considered separate in terms of probability?
- How to show that an expression of a finite type must be one of the finitely many possible values?
- Follow Up: struct sockaddr storage initialization by network format-string
- Checking system vs. SEPA and the like
- Bulk update symbol size units from mm to map units in rule-based symbology
- Time arrow with "current position" evolving with overlay number
- Can airtags be tracked from an iMac desktop, with no iPhone?
- How can I find out which sectors are used by files on NTFS?
- Is a PhD visitor considered as a visiting scholar?
- Is it correct to use "the" before "materials used in making buildings are"?
- Does a summoned creature play immediately after being summoned by a ready action?
- How do I align things in the following tabular environment?
- Why are trials on "Law & Order" in the New York Supreme Court?
- Who owns code in a GitHub organization?
- Counting Letters in a String
- Knocking Out Zombies
- How to react to a student’s panic attack in an oral exam?
- A limit involving the quotient of two sums
- How do you get out of a corner when plotting yourself into a corner
- How to follow the signal when reading the schematic?
- Has 90% of ice around Antarctica disappeared in less than a decade?
- remove package from CTAN
- What is a word for the arcane equivalent of a monastery? A place where magic is studied and practiced?
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .
- Stack Overflow Public questions & answers
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Talent Build your employer brand
- Advertising Reach developers & technologists worldwide
- About the company
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Run Outlook macro from desktop shortcut
I am trying to run an Outlook 2013 macro from a desktop that I have already made and works good. I would like to be able to copy this shortcut to other coworkers computers as well.
Any idea's since the autorun function is not supported anymore?
- What autorun function? – 0m3r Apr 5, 2018 at 5:12
Create a desktop VBScript ( *.vbs ) that uses the Office COM Automation API to run the macro.
Something like this:
You may need to use GetObject instead of CreateObject , as well as bringing the Outlook window to foreground.

Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged vba windows outlook or ask your own question .
- The Overflow Blog
- How Intuit democratizes AI development across teams through reusability sponsored post
- The nature of simulating nature: A Q&A with IBM Quantum researcher Dr. Jamie...
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
- Launching the CI/CD and R Collectives and community editing features for...
- Staging Ground Beta 1 Recap, and Reviewers needed for Beta 2
- The [amazon] tag is being burninated
Hot Network Questions
- What can a lawyer do if the client wants him to be acquitted of everything despite serious evidence?
- nicematrix: add ttfamily in the last-col
- Recovering from a blunder I made while emailing a professor
- Why are Suriname, Belize, and Guinea-Bissau classified as "Small Island Developing States"?
- Where does this (supposedly) Gibson quote come from?
- How to tell which packages are held back due to phased updates
- Why do small African island nations perform better than African continental nations, considering democracy and human development?
- What is a word for the arcane equivalent of a monastery? A place where magic is studied and practiced?
- How does fire heat air?
- Coasting Along the Coast
- Tips for golfing in SVG
- If you preorder a special airline meal (e.g. vegan) just to try it, does this inconvenience the caterers and staff?
- Short story taking place on a toroidal planet or moon involving flying
- How to follow the signal when reading the schematic?
- Doubling the cube, field extensions and minimal polynoms
- OK to delete Windows.db file on PC?
- Did any DOS compatibility layers exist for any UNIX-like systems before DOS started to become outmoded?
- Do new devs get fired if they can't solve a certain bug?
- Time arrow with "current position" evolving with overlay number
- Why do many companies reject expired SSL certificates as bugs in bug bounties?
- What is the purpose of this D-shaped ring at the base of the tongue on my hiking boots?
- My code is GPL licensed, can I issue a license to have my code be distributed in a specific MIT licensed project?
- Can archive.org's Wayback Machine ignore some query terms?
- QGIS - Countif function
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

Create or Generate Keyboard Shortcuts for Microsoft Office
Make your tasks so much easier
A mouse is a handy tool, but point-and-click is a waste of time. You knew that, so you went and learned the best keyboard shortcuts for Office and Windows already.
But maybe some repetitive tasks don’t have shortcut keys. Wouldn’t it be great if you could create your own keyboard shortcuts in Microsoft Office? Well, you can.

How to Create Keyboard Shortcuts in Microsoft Office
Let’s go through these steps in Word first. The steps are identical in Excel and PowerPoint on the desktop. Scroll down to see how to do this in Outlook.
- Right-click on any grey space in the ribbon area and select Customize the Ribbon .

- The Word Options window will open. Select Customize next to Keyboard shortcuts near the bottom of the window.

- The Customize Keyboard window will open. Look in the Categories area to narrow down to a tab which has the command you want to create a shortcut for. That tab’s commands will show in the Commands area on the right. Select the command you want. In this example, we’ve selected FileSendPdf , as it would be very helpful to send a Word document as a PDF with a simple keystroke combination. If the command already has a keyboard combo, it will show in the Current keys area.

- To set a new shortcut key combination, place the cursor in the Press new shortcut key field, then press the key combo you want to use on your keyboard. Make a note of what shows under the Current keys area next to Currently assigned to . If anything but [unassigned] shows there, try another key combo.

- To use this key combo for all future documents, leave Normal.dotm selected in the Save changes in box. To apply the key combo to only this document, choose it in the drop-down box.
- Select the Assign button to apply the settings, then close the Customize Keyboard window. Press OK to close out the Word Options window. Try your new keyboard shortcut combination.

The FileSendPdf shortcut will automatically convert the document into a PDF, create a new email message in Outlook, attach the PDF, and give the email a Subject. One keystroke instead of a dozen or more point-and-clicks with a mouse is an incredible timesaver.

How to Clear Custom Keyboard Shortcuts in Microsoft Office
You may wish to get rid of all the custom keyboard shortcuts you’ve made in an Office app. It’s simple to do.

- The Word Options window will open. Select the Customize button in the bottom-left area of the window. The Customize Keyboard window will open.

- To remove the key assignments from all future documents, leave Normal.dotm selected in the Save changes in drop-down. To remove them only from this document, choose the document in the dropdown instead. Near the bottom-left, select the Reset All button.

- It will ask, Are you sure you want to reset the key assignments? This action will remove all keys currently assigned to macros and styles in Normal.dotm . Note that at the end of that warning, it will read either Normal.dotm or the document you’ve selected. Select Yes to confirm the reset.

How to Create Keyboard Shortcuts in Microsoft Outlook
Of all the Microsoft Office apps, Outlook is probably the one in which you spend the most time. It makes sense to create some custom keyboard shortcuts to get things done faster.
Unfortunately, since Outlook 2016, it doesn’t allow you to make keyboard shortcuts as we can in Word, Excel, and PowerPoint. So what are your options?
It’s a workaround, but you can create Quick Steps and assign key combinations to them. This won’t give you the ability to create a shortcut key combo for everything in Outlook, but it can meet most of your needs. There is a limit of nine key combos that you can assign to custom Quick Steps.
- Select Create New in the Quick Steps section of the Home tab in Outlook.

- The Edit Quick Step window will open. Enter a descriptive name in the Name field.
- Choose from one of the predefined actions in the Choose an Action drop-down menu. In this example, let’s go with Mark as read .

- String actions together by selecting the Add Action button under the previous action.

- Select Move to folder .

- The Select Folder window will open. Find and select the folder to which you want this Quick Action to move the email. We select the folder Bills for this example. Select OK to close the window.

- Select a key combo in the Shortcut key drop-down. Note that it’s limited to nine selections.

- Add a description of what the Quick Step does in the Tooltip text box. When you hover over the Quick Step later, this will appear to remind you of what it does.
- Select Finish to complete creating the Quick Step. You’ll now see the Mark Read Move to Bills Quick Step in the Outlook ribbon. Test it using the shortcut key combo you chose in step 7.

If you want to go a step further, you can create Outlook Desktop shortcuts using command line switches to make common tasks easier to do.
Practice Your Keyboard Shortcuts
Now you can create your own Microsoft Office shortcut keys. Print out a list of your most-used shortcuts and keep them beside your monitor. After a few days, you won’t need the cheat sheet anymore. Add in the command line switch shortcuts and it will boost your Microsoft Office productivity in no time.
Guy has been published online and in print newspapers, nominated for writing awards, and cited in scholarly papers due to his ability to speak tech to anyone, but still prefers analog watches. Read Guy's Full Bio
Read More Posts:

Subscribe to Help Desk Geek.
Join 30,000+ others who get daily tips, tricks and shortcuts delivered straight to their inbox.
Thanks for subscribing!
We will never spam you, unsubscribe at any time.

More results...

2 Ways to Assign Keyboard Shortcuts to Macros
Bottom Line: Learn two different ways to create keyboard shortcuts to run macros, and discover the pros and cons for both methods.
Skill Level: Intermediate
Download the Excel File
You can download the example Excel file I use in the video here:
Create Your Own Keyboard Shortcuts to Run Macros
Assigning keyboard shortcuts to simple or complex macros can help you work faster in Excel. This is especially true if you have to perform the same actions repeatedly. In this post we look at two popular ways to create the shortcut keys. These include the Macro Options window and VBA code for the Application.OnKey method. I also explain the pros & cons of each method.
1. The Macro Options Window: Shortcut Key
We can use the Macro Options window in Excel to create a shortcut key to call the macro. Here are the instructions on how to set it up.

Be careful not to override an existing shortcut that you frequently use, such as Ctrl + C to copy. One way to avoid doing this is by adding Shift to the shortcut to make it a bit more complex. In my example, I used Ctrl + Shift + C .

To delete the shortcut , simply repeat the process for accessing the Macro Options Window and then delete the character that you entered to create the shortcut.
2. The Application.OnKey Method in VBA
We can also use VBA code to create shortcut keys for macros. The Application.OnKey method allows us to create and delete the shortcuts. It also gives us more options and flexibility with our keyboard shortcuts.
Start by accessing the VB Editor. You can do this by clicking the Visual Basic button on the Developer tab, or pressing Alt + F11 .

Create Shortcuts with OnKey
In the VB editor, we are going to write some simple code to assign a macro to a keyboard shortcut .
- Create a new macro and name it CreateShortcut (or whatever you choose to name the procedure),
- Add a new line and start it with the command Application.OnKey followed by a space. The Application.OnKey method has two parameters for the Key and Procedure. The Key is the keyboard shortcut combination represented by key codes. The Procedure is the name of the macro that will be called when the key combination is pressed. Both parameters are enclosed in quotation marks.
- In my example I use “+^{C}” for the Key parameter. The + is the code for Ctrl , the ^ is code for Shift , and the C key is enclosed in curly brackets (or braces). How are you supposed to know the code for each key? Microsoft has this helpful document , which contains a complete list.
- Following this code, you are going to name the procedure that you want to assign to that combination of keys. In this case, we want the key combination to run the macro called “CellColorGreen”.

Delete Shortcuts with OnKey
As you can also see in the image above, the code to delete this process is simple. I've typed it just below the section for creating the shortcut. Instead of “CreateShortcut” we will call it “DeleteShortcut” and we remove the procedure name (“CellColorGreen”) from the code. The absence of a procedure tells Excel not to assign an action to that combination of keyboard strokes.
This also resets the key combination to any native Excel keyboard shortcuts. For example, if we were using Ctrl + C instead, the keyboard shortcut would revert back to performing the Copy action when Ctrl + C is pressed.
Both the Create and Delete macros can have multiple lines of code with the OnKey method. This allows you to setup different shortcuts for different macros all at the same time.
Automate OnKey with Events
However, you can actually automate this by using the Workbook_Open and Workbook_BeforeClose events. Here are instructions on how to set it up (see the video above for more details).

If your macros are stored in your Personal Macro Workbook , you can follow the same procedure as above. Checkout this article on how to create your own Personal Macro Workbook if you don't have yours setup yet.
Pros & Cons for Each Method
For both methods, the keyboard shortcut can be used on any file we have open in Excel, as long as the file that contains the macros remains open. Let's look at some of the advantages and disadvantages for each method.

Pros: Macro Options Window
- With this method, keyboard shortcuts are really easy to set up and can be a little more appealing to people who might be intimidated by writing code.
Cons: Macro Options Window
- You are limited in terms of the keys that can be used. Unfortunately, you can't use special keys such as Home , End , Page Up , etc.
- The user might already have the same shortcut key assigned, so if you as the developer assign one for the workbook, you can't control which one (yours or the user's) will run. The order it runs in is based on the alphabetical order of the macro names in all open workbooks on the user's computer.
- There's no list or index of the shortcut keys you've created, and there is no way to search to find them. So if you've created several and can't exactly remember, you may have trouble keeping track of what keys are out there. There are macros that can help create this list, but this takes extra work every time you want to see your shortcuts.
Pros: Application.OnKey Method
- You can easily look up your keyboard shortcuts by by searching the VBA code for the word “onkey.” Use the Find window ( Ctrl + F ) in the VB Editor.
- If multiple macros or workbooks use the same shortcut, you can control the order or priority of the macros that run. Shortcuts created with the OnKey method will supersede those created with the Macro Options window. So, running the OnKey method will ensure that the macro it references is run when the shortcut key is pressed.
- The keyboard shortcuts are easy to delete or remove. We can create macro buttons in the Ribbon to enable or disable keyboard shortcuts. Or, we can even use a keyboard shortcut to toggle our keyboard shortcuts. 🙂
- You are able to use special keys besides Ctrl + Shift (such as Alt , Home , End , Page Down , etc.). The Ctrl + Alt combination gives us a lot more options for shortcut keys.
- Dynamic shortcuts can change the procedure that is called based on conditions in the workbook.
Cons: Application.OnKey Method
- You must update your code if the macro name changes.
- You have to actually run the macro to assign shortcuts.
The Verdict
So which method is better for macro shortcuts? Well, my preferred way is the OnKey method .
With the OnKey method: it is much easier to find and see all of our shortcuts, we have more key options, and more control over quickly enabling/disabling multiple shortcuts.
There is no perfect solution, but I recommend using the OnKey method if you are going to set up multiple shortcuts in your Personal Macro Workbook .

If you like using keyboard shortcuts to make your work faster and more efficient, I recommend you check out my posts 18 VBA Macro Shortcuts and also The Best Keyboards for Excel Shortcuts .
I'd love to hear about the most useful shortcuts you've created, or want to create. Please comment below to let me know or to ask any questions you might have about assigning keyboard shortcuts.
You may also like

Remove Multiple Levels of Indenting

3 Ways to Remove Duplicates

Find and Replace Formatting in Excel

Excel Bad Habit #11
Excellent, very well explained, thank you…..
Thank you Mark! 🙂
I enjoiyed this one. I have quite some macro’s in my PMW. SinceI followed the VB-Pro Course, I’ve setup a custom tab with buttons to run the macros I most use. Now I’m going to add shortcuts as well using the “Application.OnKey”.
Thanks again Jon.
Awesome! Happy to hear about all the macros in your PMW, and excited for all the progress you’ve made. Thanks Edil! 🙂
Hi Jon, Thanks for the valuable explanation. A few weeks ago you pointed me to the Onkey method. And I thought of this only as a method to use when there is no Ctrl+Shift shortcut available anymore for a certain letter with Macro Option.
But the tracking and maintenance aspect is indeed relevant. It was today very easy for me to find all my Onkey shortcuts (5), but the very first Macro Option shortcut comment I found in a module was wrong. I had deleted the shortcut as it was in conflict with a built-in shortcut (and I had brought a button to the QAT, so it was also somehow obsolete).
With built-in shortcuts and all the shortcuts for macros or e.g. paste buddy there is the danger that one pushes a wrong combination – and macros can’t be undone. Any ideas for a naming convention that could bring in some structure or grouping and would helps to differentiate more easily?
Thanks again!
Instead of using one shortcut key per macro (e.g. Ctrl+Shift+1, Ctrl+Shift+2), you can use one shortcut key that displays a menu of macros, selectable with a simple (or few) character(s) (e.g. F12 then 1, F12 then 2).
You can also use a VBA Enterpad to trigger your macros without using any shortcut keys at all.
Hi Matthias, For macros that clear the undo history you might want to have a Yes/No message box appear before they run.
Video #4 on this page on The Personal Macro Workbook explains how to add the Yes/No message box to any macro.
The Yes button on the message box has focus set to it by default. So all you have to do is press Enter when it appears. This is one way to prevent accidental keyboard shortcut presses that are assigned to macros.
I hope that helps answer your question.
It is a pleasure to watch a professional at work. Not only are you well versed in Excel but your presentation is well organized AND presented. There is nothing more distracting than listening to a speaker who frequently pauses with ‘ahhs’.
Thank you for the article, but the + is the code for Shift, the ^ is code for Ctrl.
Fantastic Video. I am pretty familiar with macros, but this video taught me 5-6 things I did not know. It was well presented, and at a great pace. Thanks!
It is MORE QUICK to write the code for shortcut into macro itself. Please write this way:
Sub MACRO_NAME () Attribute MACRO_NAME.VB_ProcData.VB_Invoke_Func = “X\n14”
After this you can write the code you want.
“X\n14” mean that when Ctrl+Shift+X is pressed, macro is started. You can change X with any other letter.
If the letter is capitalised, then the Shift key is used (and respective letter). If the letter is NOT capitalised, then just Ctrl key is used (and respective letter).
Keep the good work!
I have a macro from a long time ago and I saw that it was already assigned a bunch of shortcut keys. Do you know how I can run a macro to see all my assigned keys? Basically, I was wondering if you would be able to help me find a macro to uncover the problem you stated in Con #3 on the macro options window…
Jon, looks like the macros called by the OnKey method need to be placed in the “ThisWorkbook” or Module. Is there any way to reference a macro that is stored within a specific sheet? I didn’t see it referenced in your video or in the MSDN help page. Any idea on the correct way to format the code to reference a macro stored on a sheet?
I wanted to know if a macros is possible which using onkey “% {DOWN}” (alt + down arrow) I immediately enlarged the column width of that cell to 50 and then when leaving that cell the column width is 5 for example.
it’s possible?
I created a macro for a specific number format and assigned Ctrl + Shift + N to it. The macro will run if I go into the macros window and press Run but not using the shortcut. Any thoughts?
Thanks, Mardi
Hello and thank you for the wonderful education. I am quite new at macros and VBA codes, so playing with some spreadsheets and data that I have put together. My questions are: – 1. Is there a way of allocating this type of macro / VBA code to a button? e.g. Either a shape or macro button, where when you press on the button it will take you to the end of the spreadsheet and one at the end to return home. 2, If you keep entering data and the end is now further down in the spreadsheet will the button automatically take you to the new end?
Thank you and sorry for my ignorance Martine
Pl. send me VBA code or any other method to 1. Jump to any worksheets 2. Rename multiple sheets as per a list. Thanks & Regards VENU. P.K [email protected]
Could you please help me with creating a macro for different keys the different comments display on Excel sheet.
For ex : if we press Ctrl+shift+A the particular Cell should display as “Tutorial”. And next Ctrl+shift+B the cell should display “Classes”
Please help me to get this.
Thanks you…
Thanks for a great tutorial. FWIW, your video contains an error. At about 10:46 your voiceover says “control alt” but the code on-screen is “+%” which is “shift alt”.
OnKey instructions were very helpful!
Annoyingly, i have done this absolutely perfectly but when i press my shortcut keys i get “no cells found” yet when i run the code manually it works without a problem. DAMN YOU MICROSOFT!
Excel Shortcuts List

Learn over 270 Excel keyboard & mouse shortcuts for Windows & Mac.
Join Our Weekly Newsletter
The Excel Pro Tips Newsletter is packed with tips & techniques to help you master Excel.

Session expired
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.
How to use Outlook's VBA Editor
Slipstick Systems
Last reviewed on June 19, 2021 307 Comments
The steps are the same for all versions of Outlook and all Office applications
It's easy to find code samples on the Internet, but unless you know how to use them, they aren't going to do you much good.
We're going to assume the code is 100% ready-to-use, not a code snippet that is half complete.
If the code will be run against items in your mailbox or personal folders, you should make a backup of the mailbox or data file, just in case something goes wrong with the code. If the code runs against a specific folder, copying the folder and contents may be enough "insurance", (You should have routine backups regardless, but I know many users don't bother.) At least very least, make a copy of the items in the folder you are running the code against.
Check Macro Security Level
Before you begin, you'll need to check your macro security setting, otherwise, you'll need to use selfcert.exe to sign your macros to test them.

Outlook 2007 and older: Access the dialog to change the security level from Tools, Macros, Security .
Outlook 2010 and up: File, Options, Trust Center, Trust Center Settings, Macro Security .
It's highly recommended that you set the Macro Security level to only allow digitally signed macros. Do not choose the Low option (run all, never ask), except during testing. Note that some security software will set it to High and your macros will not run. You may need to restart Outlook after changing the security setting.
Open the VBA Editor
Now you are ready to open the VBA Editor. Press Alt+F11 on your keyboard, or if you are showing the Developer ribbon, click the Visual Basic Editor command to open it. In Outlook 2007 and older, the command in on the Tools, Macros menu.

If your screen does not resemble the screenshot above, with the white editing pane open, you'll need to click on Microsoft Outlook Objects to expand it then double click on ThisOutlookSession to open it in the editing pane on the right side. To add a module to the VBA project, right click on Project1 and choose Insert > Module to insert a new module.
Generally speaking, you can put the code into either ThisOutlookSession or a Module , unless otherwise noted that it must be in ThisOutlookSession or a module.
Application_Start macros must be in ThisOutlookSession .
Starting out with Outlook Macros Video Tutorial
This video tutorial shows you have to change the macro security settings, add a macro to Outlook, run the macro, and then create a digital signature using SelfCert.exe to sign the macro before increasing macro security.
Set a reference to other Object Libraries
If you receive a " User-defined type not defined " error, you need to set a reference to another object library.
- Go to Tools, References menu.

Commonly used libraries are Microsoft Word, Microsoft Excel, Microsoft Forms, and VBScript Regular Expression.
Run the Macro

Ctrl+Break will pause the macro, or press the Stop button on the toolbar to end it.
If you will be using the macro often, you should use selfcert to sign it then set Macro Security to only allow signed macros.
Don't sign the macro until you are done tweaking it and if you tweak it later, you'll need to re-sign it.
To run the macro from Outlook 2007 or older, go to Tools, Macro, Macros and select the macro. In Outlook 2010, you need to show the Developer ribbon first (File, Options, Customize Ribbon - check Developer ribbon on the right). You can also open the Macros dialog using Alt+F8 (all versions). You can also add macros to toolbar or ribbon buttons.
Using SelfCert to sign a macro
To sign a macro using selfcert , you first need to create a certificate. You can find selfcert in the folder with your Office files. In Outlook 2010 and older (as well as Outlook 2013 in volume licensing), selfcert is usually at C:\Program Files\Microsoft Office\OfficeXX where XX is your version of Office.

In Outlook 2013 and 2016 "click to run", users will find selfcert at C:\Program Files\Microsoft Office 15\root\office15 (or Office16), or in C:\Program Files (x86)\Microsoft Office 15\root\office15 (or Office16) if using 32bit Office on 64-bit Windows.
With any Office version, if you use 64-bit Windows and 32-bit Outlook, selfcert will be in the 32-bit Programs directory.
In Windows 8 or 10, you can right click on the Outlook tile on the Start screen or Start menu and choose Open File Location ( More > Open File Location in Windows 10). This opens Windows Explorer to the location of the Office shortcuts. Right click on the shortcut and again choose Open File Location to open Windows Explorer to the folder where Outlook.exe is. Type S to jump down then double click on SelfCert.exe)
It's simple to use: just type a name for your digital certificate then click ok.
Once you have the certificate, sign the macros using Tools, Digital Signature dialog and choosing a certificate. When you close Outlook, if you are asked to save the VBA project, click Yes, even if you saved it from the VBA editor.
Note that every time you edit the macro you'll need to resign it.
Using SelfCert Video Tutorial
Add Macros to the toolbar or ribbon
If you are going to be using a macro often, you will probably want to create a toolbar button for it.

You'll need to add a new Group to an existing ribbon tab or add a new tab and new group before selecting Macros from the Choose commands from menu. Select the macro and click Add to add it to the selected group in the right pane.
In Outlook 2007 ribbons: you can only add buttons to the QAT. Right click on a ribbon tab and choose Customize Quick Access Toolbar. Select Macros from the Choose commands from menu then select the macro and Add it to the right pane. (When you add buttons to the QAT you can use Alt+ n keyboard shortcuts.)

Drag the macro from the right side to the toolbar and drop. Right click on it to edit the name and button image.
More Information
Need help with sample code? Try the forums at Outlookcode.com or the Microsoft programming forums at MSDN
Looking for sample code? Outlookcode and VBOffice.net have a large number of code samples.
About Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.
I inserted a module, put in the code, named the module, used selfcert to create a certificate, enabled signed macros (even tried enabling all macros), but still NOTHING shows in the macro box. I am using Outlook 365 in Windows 11 with Exchange. Any ideas as to what I might be doing wrong?
Hi Diane, first of all, thank you very much for what you do. I learned a lot, and continue to use a lot of your examples of VBA code in my professional life.
I need your help in an Outlook VBA code, I browsed through forums, but couldn't find a solution to this. Probably super simple.
I'm using this code to split the name of the sender, and when I hit reply, it populates the body of the email with "Hi + strName".
strName = Split(Split(olReply.To & ";", ";")(0), " ")(0)
Now, how can I get the last element of the split name?
I know it's on the last 0, but don't know how to get there. You see because some people have 3 names, and some have only 2.
And I would like to get always the last index since the order of names is Surname (MiddleName, sometimes) FirstName.
Can you help?
In the section "Using SelfCert to sign a macro" you say "selfcert is usually at C:\Program Files\Microsoft Office\OfficeXX".
I believe that (unless you are using 64 bit Outlook) the correct path would be : "C:\Program Files (x86) \Microsoft Office\Officexx"
It would be in the same folder as the rest of the office apps - so, yeah, for 32 bit on 64bit windows, it would be in the x86 path. I wrote it back when 32-bit was still the thing.
In the section "Using SelfCert to sign a macro" you say "Note that every time you edit the macro you'll need to resign it."
I have not found this to be true in my Outlook 2010. Once I have signed my project it does not require me to resign it no matter how extensive the changes. I have to assume you are right and I am wrong. So, what am I missing?
I am looking for a steer towards the correct code to enter in the ThisOutlookSession module that, for incoming mail items, gets the senders email and searches my outlook contacts (including) subfolders. Upon finding a match, gets the contact item category and automatically applies the same category to the mail item.
Can this be done?
https://www.slipstick.com/developer/categorize-messages-using-contact-category/
It should work with all contact folders that are enabled as address books or for 'check address before sending' in address book options.
thank you for your reply. I have tried this code before and again following your comment.
Although it returns no errors within outlook at startup, I get no positive results. If I invoke the assign macro manually (as per the code comments) in existing inbox items it does nothing.
Hence, the shout out
Are the contacts in the default contacts folder?
Add msgbox lines throughout to see if they pop up - before end sub in app startup add msgbox "Started"
before the statement in the macro that sets categories- add msgbox "Sender is " & Item.Sender
after the line to set oContact, add msgbox "oContact is " & oContact.name
All my contacts are in subfolders within contacts. There are no contact records at the top level
That could be the problem. I'm out of town for a family emergency, but will take a look at making it work when I come back.
Great, thank you - the solution is alluding me at present
Posted on the wrong article - please ignore.
My value for Birth Month.Day for a Start of Oct 1st and Oct 10th both return the same decimal value on my table view as "10.10". My manual sort is naturally out of order. Thank you for any help!
You need to use 4 digits - 10.01 and 10.10
Hello I need some help please. I have created a form outlook to be filled in but unable to get the right vba code. I was able to create the form in excel and code it to work as it should. But unable to duplicate it in outlook. Can you assist please.
I am needing to modify the calendar explorer to show multiple appointments that start at the same time vertically instead of horizontally just arranged alphabetically and expanding the cell as needed. I would also like the ability to add a Boolean for "completed" on the Appointment form and added to the context menu, and when true, change the color of the calendar item. Also, since this will be published to a WebDAV server, I would like at least the completed property to be sent along with updates..
Calendar Tools
Schedule Management
Calendar Printing Tools
Calendar Reminder Tools
Calendar Dates & Data
Time and Billing Tools
Meeting Productivity Tools
Duplicate Remover Tools
Sending and Retrieval Tools
Mass Mail Tools
Compose Tools
Mail Tools for Outlook
Online Services
Productivity
Productivity Tools
Automatic Message Processing Tools
Special Function Automatic Processing Tools
Housekeeping and Message Management
Project and Business Management Tools
Choosing the Folder to Save a Sent Message In
Run Rules on messages after reading
Help & Suggestions
Outlook Suggestion Box (UserVoice)
Slipstick Support Services
Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer Outlook for Mac | Common Problems | Utilities & Addins | Tutorials Outlook & iCloud Issues | Outlook Apps EMO Archives | About Slipstick | Advertise | Slipstick Forums Submit New or Updated Outlook and Exchange Server Utilities Send comments using our Feedback page Copyright © 2023 Slipstick Systems. All rights reserved. Slipstick Systems is not affiliated with Microsoft Corporation.
Sign up for Exchange Messaging Outlook
Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)
Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.
Never see this message again.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Using Visual Basic for Applications in Outlook
- 3 minutes to read
- 6 contributors
Visual Basic for Applications (VBA) makes it easy to control Microsoft Outlook within Microsoft Outlook itself. Using VBA in Outlook, you can create macros that perform complex or repetitive tasks automatically. You can also develop program code that responds to Outlook events, allowing you to automate common tasks (such as arranging windows when Outlook starts).
Visual Basic for Applications allows you to take almost full advantage of the Outlook object model, including the wide range of application-level events, without requiring you to run an external application (such as another Microsoft Office application or an application developed using Microsoft Visual Basic). And unlike form scripts developed using Microsoft Visual Basic Scripting Edition (VBScript), Outlook Visual Basic for Applications code is always available in the application; an item does not have to be open to run the code.
All Outlook Visual Basic for Applications code is contained in a project. The project is associated with a particular user, so all users who run Outlook on a computer can customize Outlook to meet their own needs. A project can contain code modules and User Form modules (note that User Form modules are not the same as Outlook forms ).
You use the Visual Basic Editor to create and remove modules, to design User Form modules, and to edit code in modules. This editor provides a powerful set of tools, including a built-in Object Browser and debugger to make developing and troubleshooting code easy. You can even use the Visual Basic Editor in Outlook to develop and test code that you can then copy to a standalone Visual Basic application or a Visual Basic for Applications application in another Microsoft Office application.
Managing Multiple Visual Basic for Applications Projects
Outlook supports only one Visual Basic for Applications project, Project1, at a time. You cannot add and run another project in the Visual Basic Editor at the same time. Project1 is stored on your hard disk as VbaProject.OTM; each user on the same computer can have a copy of VbaProject.OTM stored for him or her. On a computer running Windows XP, VbaProject.OTM is in <drive>:\Documents and Settings<user>\Application Data\Microsoft\Outlook.
Because you can run only one Visual Basic for Applications project at a time, before you run a different project, you should exit Outlook, rename the current VbaProject.OTM with a different file name, name the project you want to run as VbaProject.OTM, and restart Outlook to run it. If appropriate, you can also manually integrate the projects to form one VbaProject.OTM to avoid the file naming and renaming.
Outlook Visual Basic for Applications code was designed to be a personal macro development environment, and was not designed to be deployed or distributed. To move a project from one computer to another, for example, moving the project from your work computer to your home computer, you can export the forms and code modules from the work computer and import them to the home computer. You can also copy and paste the source code of the project to Project1 on the home computer using the Visual Basic Editor.
If you are developing a solution that you intend to distribute to more than a few people, you should convert your Visual Basic for Applications code into an Outlook COM Add-in. However, developing a COM Add-in typically requires considerably more programming knowledge than creating a short macro, so if your Visual Basic for Applications project is relatively simple, and there are not too many people who need to use it, you may want to send them the code with instructions on how to set it up.
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Additional resources
Ultimate Guide To Create Macros and Assign Shortcut key In Microsoft Word | 2022
Macros are small sets of codes that allow you to perform repetitive activities. We use macros on documents that have vital data and simplify the work on the word document. However, a wrong command or code can be harmful to your document and make you lose your data permanently. In case you have a word document with such issues, we have a solution for that in form of a Remo Word Repair Tool. Make use of it to repair a damaged word document into a healthy safe file.
- Free Download For Windows
- Written By Tony Landry
- December 16, 2022
If you are one of those Microsoft Word users regularly performing a repeated set of activities, then Macros are for you. Creating Macros will not only make your work easier by just assigning a shortcut key but also helps you a lot of time. Follow this article, to learn how to create Macros and add a shortcut for Macros in a Word document.
What are Macros?
Macros in a Word application i s a short piece of code that runs in the background. Creating Macros in Word can help you improve your work experience with Microsoft Word by finding a shortcut for repeated sets of actions on it.
Say you want to run a formula or insert a template into your Word document regularly for multiple Word files, Macros can do this in just a simple assigned keystroke saving you time and effort.
Creating Macros in Word doesn't require you to be a technical geek. You can simply create Macros by using the Macros Recorder to record a sequence of actions. To create Macros, you are required to assign the specific key combination to perform repeated actions on any of your Word documents.
NOTE: Macros in Microsoft Word can also pose a threat to be used as a potential malware vehicle to corrupt the Word document. In order to avoid corruption of Word files, it is recommended to maintain a backup copy of word documents. If you are facing any issues with MS Word then read more to learn how to protect Word documents .
How to Create Macros and Assign Shortcut Keys on Word?
You can create and assign macros a shortcut key by following the steps given below

- Once, you complete the typing of your documents and have assigned a shortcut key for Macros then stop Macros recording by clicking on the Macros > Stop Recording .
- Finally, to run your Macros click on the Button option.
How to Add a Shortcut Key for Existing Macros?
If you have existing Macros then you can assign shortcut keys. This results in Macros being executed. Follow the steps below to assign a shortcut key for existing Macros
- Choose File > Options and then click Customize Ribbon .
- Click the Customize button that is present next to Keyboard Shortcuts (near the bottom of the dialog box). Now, the Customize Keyboard dialog box appears.
- In the Categories list, scroll down and click Macros .
- A list of the Macros will appear
- Select the Macros for which you need to assign the shortcut
- Then, type the Shortcut Key of your choice and hit Close .
Now try pressing the assigned shortcut key in the same document to which you created the Macros. Your Macro should run perfectly and perform all the actions that were recorded.
Since Macros are small pieces of code written in a programming language, much like any other software program. You cannot rule out the chances of incorrect codes damaging the document or the virus threat to the document. In such cases, you will not be able to access your Word document.
It is recommended to use Remo Repair Word for free , a powerful word repair tool specially designed to repair corrupt or damaged Word in a few clicks only. This Word repair tool is built-in with advanced repairing algorithms that help to repair the corrupted word document to recover its content without any alteration. You can recover all your content, formatting, alignments, hyperlinks, images, etc. All of this can be tried completely free. Download the tool and start repairing the document now.

Repair Word document with Remo Repair Word
- Download and install Remo Repair Word.
- Launch the software and click on the Browse option to select the corrupt .doc or .docx file.

3. Click on the Repair option to start repairing the Word file.

4. Once the Word document is repaired, you can preview the file to judge the success of the software.
5. Select the Save option to save the repaired Word file to the desired location.

Hope this article was helpful in creating Macros and adding a shortcut to the Macros. Do share this article if you found it helpful and let us know your thoughts and queries in the comment section below.
- Photoshop Shortcut Keys | Guide 2022
- Microsoft Word Crashing - Scenarios and Solutions | 2022
- Microsoft Access 2010 Shortcut Keys
- Microsoft Word 2010 Shortcut Keys
Tony Landry
Tony Landry is a Web Content Editor at Remo Software. He loves to write, edit, and manage content for users trying to troubleshoot and fix problems on Windows, Outlook, storage drives and Cloud storage networks.
He has published more than 200 articles in Remo Software blog. He actively engages in research and problem-solving techniques to consistently generate great web content. Fixing various hardware problems on computer and storage devices along with a great knack for fixing Outlook errors, Tony is also the fun-time IT guy for all his work friends. He lives in the San Francisco Bay Area and enjoys cycling.
Leave a Reply Cancel Reply
Name *
Email *
Save my name, email, and website in this browser for the next time I comment.
Post Comment

IMAGES
VIDEO
COMMENTS
The keyboard shortcut to bring up the Macros dialog box is ALT+F8. This shortcut works even when the Developer tab isn't enabled. Create a button on the Quick Access Toolbar The Quick Access Toolbar (QAT) is the line of icons that appears above the Ribbon and is placed within the Title Bar of the window.
Use keyboard shortcuts to add accent marks and special characters To add accents or special characters, use the number pad on your keyboard with Num Lock turned on. Press and hold Alt. Type the numeric code on the number pad and release Alt. Top of Page Vowels with accents
To create or edit a macro by using Visual Basic for Applications (VBA), do the following: On the Developer tab, choose Macros. See Show the Developer tab to learn how to display the Developer tab. In the Macro dialog box, type a name for the macro. Click Create to open Visual Basic for Applications (VBA). Run a macro
In Outlook, on the Developer tab of the Microsoft Office Fluent ribbon, click Visual Basic. In the Project window, double-click the module you want to contain the macro. On the Insert menu, click Procedure. In the Name box, type a name for the macro. The name cannot contain spaces. Click OK.
I know how to create a tool for the macro and put it in a menu with an underscore shortcut. This solution requires me to use a shortcut of Alt + {menu key} + {tool key}. What if I want to assign it to Alt + F12 or something like that? The Visual Basic Editor is assigned to the keyboard shortcut Alt + F11 in Outlook 2007.
Outlook does not support assigning shortcut to macro like Word does. The best approach I can think of is to add a command to Quick Access Toolbar and use Alt+(Number correspond to the command). Since your issue is relate to the usage of Outlook, I suggest you repost it on the Outlook Answers Forum as well. Hope it helps. Best regards,
Next, in the VBA Editor go to Tools > References and select Microsoft Word 14.0 Object Library. Now, to create a keyboard shortcut for a macro, add it to your Quick Access Toolbar as follows: Open a new mail message; Click on the small drop down arrow on the Quick Access Toolbar (typically located at the top of the window) and select "More ...
Create a desktop VBScript ( *.vbs) that uses the Office COM Automation API to run the macro. Something like this: Option Explicit Dim outlook Set outlook = CreateObject ("Outlook.Application") outlook.Run "MacroName". You may need to use GetObject instead of CreateObject, as well as bringing the Outlook window to foreground. Share.
Macros are for manipulating documents, or parts of them, not for typing text in Word. You would not want to reassign the function keys (or at least I would not want to) because they all have useful assignments in Word already. However Alt- Ctrl- Ctrl-Alt Shift-Alt- and Ctrl-Shift-Alt- combinations with letters are all available.
Shashirekha. To insert auto text in your emails you can follow the steps given below:-. 1. Type your text into the email body area. 2. Highlight the text you want for your AutoText Entry. 3. Once the text is highlighted... click at Insert > AutoText > New (Or you can simple hit Alt+F3). 4.
Right-click on any grey space in the ribbon area and select Customize the Ribbon. The Word Options window will open. Select Customize next to Keyboard shortcuts near the bottom of the window. The Customize Keyboard window will open. Look in the Categories area to narrow down to a tab which has the command you want to create a shortcut for.
After selecting the macro that you want to assign the shortcut to, click the Options button. In the Macro Options Window, you can create the shortcut you want by adding a letter, number, or symbol. Be careful not to override an existing shortcut that you frequently use, such as Ctrl + C to copy.
The macros on this page should be placed in a module. Open the VBA Editor by pressing Alt+F11 on your keyboard. To put the code in a module: Right click on Project1 and choose Insert > Module Copy and paste the macro into the new module. More information as well as screenshots are at How to use the VBA Editor More Information
In Outlook 2007 (main interface) and older versions of Outlook: right click on the toolbar area and choose Customize. Switch to the Commands tab and find Macros on the left. Drag the macro from the right side to the toolbar and drop. Right click on it to edit the name and button image. More Information Need help with sample code?
In this article. Visual Basic for Applications (VBA) makes it easy to control Microsoft Outlook within Microsoft Outlook itself. Using VBA in Outlook, you can create macros that perform complex or repetitive tasks automatically. You can also develop program code that responds to Outlook events, allowing you to automate common tasks (such as ...
Now, to assign a shortcut for Macros, click on the Keyboard icon and click on the Assign button to add a shortcut key for Macros. An example of a shortcut key is (shift+ctrl+d). Once, you complete the typing of your documents and have assigned a shortcut key for Macros then stop Macros recording by clicking on the Macros > Stop Recording.