Macro keyboard shortcuts not working in new macro template document

Copper Contributor

I want to be able to create a new Word document that has my usual set of macros & keyboard shortcuts enabled. I'm having trouble doing that.  

I made a Normal.docm template. I called it MacroTemplate & made it so that it shows in the set of templates that appear when I click File > New.  

I create a new doc based on that template. The macros show in the document.  I can select them & run them.  The keyboard shortcuts show in Customize Keyboard, but do not work to run macros. 

I have a clunky work-around that I can do to get them to work, but don't want to have to do this step every time that I create a new document.  I always want every new document to be created with this set of macros enabled with working keyboard shortcuts!  

 

An example is my InsTodayDate macro with a keyboard shortcut of Alt+D.

  

A way that I can get them to work is to go into the Macros Organizer.  In my Normat.docm template, there is a set of macros called NewMacros.  This set already exists in my current document.  They don't show in this Organizer, but they are there when I list the macros in the document.  I can use the Organizer to copy the NewMacros to my current document. 

 

Result:  My keyboard shortcut now works.  Now, in the Organizer, my current document lists all of the macros twice. The macros were not listed in my current document in this dialog before.  Now they are listed twice.  I have 46 macros I'd like in the document.  Now it lists these twice - so there are now 92. One set of 46 is prefixed with Normal.NewMacros.[macroname]. The next set of 46 is prefixed with Project.NewMacros.[macroname] - which rather proves that the macros were already there to begin with.

Interestingly - the Customize Keyboard dialog does not show them twice. It lists only the macro names - a single set of 46.

 

How can I create a new document that is macro-enabled and includes my macros & their working keyboard shortcuts?  (just like Word 2003 did - which is what I am moving from) 

Thank you!!  

 

12 Replies

@susanc06 

 

I would suggest that you start with creating a true template with the *.dotm extension. (A macro-enabled document, *.docm, is still just a document.)

 

Since you are using the name "Normal," are you trying to replace Word's predefined Normal.dotm template? That isn't a good idea. You can customize the Normal template or you can use some other template (with a different name) and load it as an add-in, by putting it in Word's Startup folder.

I already created such a template. The template that I am using is called Macrotemplate.dotm. It is in the folder C:\Users\[myname]\Documents\Custom Office Templates. It is visible when I click File > New. I don't recall but I imagine I selected that folder name, then told the software where to find it.

There is also a Normal.dotm in the folder: C:\Users\[myname]\AppData\Roaming\Microsoft\Templates. I, again, cannot recall whether I created this or whether the system did. So I don't recall whether I was intentionally changing Word's Normal.dotm or not. All my macros are in the Normal.dotm document. So I must have put them there!

When I create my macro document, I click File > New & select the template called MacroTemplate.dotm.

Should I put this MacroTemplate.dotm in the Word Startup folder? or do something else? Should I do something to change my Normal.dotm back to the default?

Thank you!
You will have to put your MacroTemplate.dotm in Word's Startup folder. That is the only way to ensure that the template is loaded into memory when Word starts. Macros and key assignments in that template will be active each time you start Word.

The Normal.dotm template is Word's default template. It is always present. If you delete it (NOT recommended) or rename it, it will be recreated.

@Stefan_Blom Was there ever a resolution to this question? I am experiencing the same issue as Susan. The issue seems to have started with the migration to Windows 11. Keystroke shortcuts for my custom macros (part of the Normal template) show up in File->Options->Customize Ribbon->Customize keyboard shortcuts (button). However, the keyboard shortcuts do NOT work! However, I am able to manually run the macros through the Developer->Macros dialog box. Please help!

@chundhau 

 

Are you saving your macros to the Normal template? Are you also saving the shortcuts in that same template? 

 

I have no idea if the original poster in this thread found a working solution, unfortunately.

@Stefan_Blom Yes, I am saving my macros to the Normal template--at least I think that is the case. I am creating the keyboard shortcuts using a  macro like this:

 

'CreateBookShortcuts
'Assigns convenient shortcut keys to the book macros
Sub CreateBookShortcuts()
    CustomizationContext = NormalTemplate
    KeyBindings.Add _
           KeyCode:=BuildKeyCode(wdKeyControl, wdKeyShift, wdKeyH), _
           KeyCategory:=wdKeyCategoryCommand, _
           Command:="FormatHTMLTag"
    KeyBindings.Add _
           KeyCode:=BuildKeyCode(wdKeyControl, wdKeyShift, wdKeyP), _
           KeyCategory:=wdKeyCategoryCommand, _
           Command:="FormatCSSProp"
    KeyBindings.Add _
           KeyCode:=BuildKeyCode(wdKeyControl, wdKeyShift, wdKeyV), _
           KeyCategory:=wdKeyCategoryCommand, _
           Command:="FormatCSSVal"

 

 

This macro is part of a module `BookMacros` that lives in the Normal' template's 'Modules' folder. When I inspect keystroke shortcuts through File->Options->Customize Ribbon, I see that the keystroke shortcuts I have defined do indeed show up:

 

Keystroke shortcut exists, but doesn't work!Keystroke shortcut exists, but doesn't work!

 

However, the keystroke shortcuts do NOT work!! The only way I can get them to run is to manually run them from the Developer->Macros dialog.

 

This is really strange. These shortcuts worked fine previous to my recent transition to Windows 11.

 

Thanks in advance for any help you can provide. 

 

Note: I have tried "Reset Macros..." and then re-running the macro to redefine the keystroke shortcuts. However, that didn't work.

 

@chundhau 

I have the exact same issue. The strange thing is that at 6 AM today, they (the macros with shortcut keys assigned) worked perfectly. At 7:35 AM, the shortcut keys to the macros stopped working. Strange thing is that I can still run my other shortcut keys assigned to styles (i.e., Heading 1, Heading 2, etc.) and other predefined functions in the MS Words. Just can't run them with my own macros anymore.

 

Please help.

@hchou56 

 

Are you running Word for Windows?

 

Are the macros and their shortcuts stored in the same template? Is the template with macros loaded as a global template or accessed by other means?

@Stefan_Blom 
I'm experiencing the same problem, although my Word randomly started to show this error since today
Screenshot 2024-01-11 114949.png
Can you please help me / us with this? My macros are also saved in the normal.dotm, but I can't even run them from the marco menu any more.

@Gandarufuuu 

You really need to post a separate question about this to get the best responses.

If you are using macros for text snippets, you are using the wrong Word feature. You should be using  AutoText, which can also have keyboard shortcuts.

 

Both AutoText and AutoCorrect can be used for text snippets. These are different features and are both valuable. I use both virtually every time I use Word.

AutoText can have keyboard shortcuts and can AutoComplete; AutoCorrect acts on trigger words as you type. Here are some more resources:

For anyone who uses Word more than occasionally, I recommend the series of short tutorials prepared by Shauna Kelly a while back. Basic Concepts of Microsoft Word - from Shauna Kelly 

 

If you haven't been using AutoText or AutoCorrect, I would guess that you may not have been using Styles to your advantage, either. The Importance of Styles in Microsoft Word 

 

If you want to track down more on your macros, I recommend looking at some of the threads you will find on the Microsoft Answers forum. Here are three searches there:

Other resources:

Thanks a lot for your help, I had no idea about AutoText Snippets. Such a clean and easy way, you saved my day!