Forum Discussion
VBA module in Word Normal Template not saved
Hi,
Windows 10 64 bits, Office Professional 2016, Word
I code in VBA7, my module is in the Normal template. Since a few days, my module is not saved correctly in Normal template when I press Ctrl-S or use the menu. It looks like it is saved in a WRLxxxx file (that's what I I see in the the VBA Editor window title), with xxxx looking random. I cannot find my code back in the Normal template at next Word session.
I tried this:
- repare Office function (didn't work)
- quit Word, rename Normal.docm, restart Word (creates a new Normal.docm), import module in the freshly created Normal template (did'nt work)
- checked add-ons : no add-ons (except inactive OneNore add-on
Can someone help ? Thank you.
Kind regards,
Jean-Pierre
- Charles_KenyonBronze Contributor
I do not know what is happening to you. If you are in a corporate setting, your IT folks may be preventing changes to Normal.dotm from being saved, or overwriting any that you do save.
Workaround:
You could save in a different Global Template instead.
Take a look at: Install/Employ VBA Procedures (Macros) by Greg Maxey
- jpgeetsCopper Contributor
Hello Charles,
Thank you so much for your quick response. On my side, I took the time to try your suggestions before answering, so please accept my apologies for the delay. My problem is not solved, but thanks to you I had deeper look in it. Strangely, it seems that if my code is less than about 10.000 lines, it fits well in Normal.dotm. Above, the problem comes back. I have no idea why. Thank you again for your help.
Kind regards,Jean-Pierre
- Charles_KenyonBronze Contributor
I keep almost all of the macros I regularly use in one or more separate global templates. Those are the macros that I have QAT buttons and keyboard shortcuts for. They are the ones that my customized ribbon uses. I have probably a thousand macros in my Normal.dot labeled as Private so they do not show up in macro lists. They are in more that fifty modules by subject/purpose. These are code snippets that I have picked up over the years and use when trying to write new code as examples. I keep backups religiously but do not really care if they all disappear (because I don't need them on a regular basis and because I have backups.
Here is my article about using a macro to save date-stamped copies of the Normal template in a separate folder.
- stefanknoobCopper Contributor
I there, I have exactly the same problem but do not see any solution anywhere ...
Regards, Stefan
- jpgeetsCopper Contributor
I now work around the problem like this:
1. delete Normal.dotm and restart Word (which creates a new blank Normal.dotm)2. set Word so that it doesn't automatically save Normal.dotm when you quit, but asks when Normal.dotm has been modified.
3. edit Normal.dotm and add a procedure called Autoexec which loads the code module (for example "MyCode.bas") when Word is launched.
4. Exit Word by answering YES (for the last time) to the question "Save the changes made to Normal.dotm".5. The code module will be loaded automatically each time Word is opened. To save the code after modification, always use the Export function in the VBA editor (export to MyCode.bas).
6. Never save again Normal.dotm, always answer "NO" to the question about saving Normal.dotm when you quit Word.
It's not very elegant, but it works for meBest regards,
Jean-Pierre- Charles_KenyonBronze Contributor
Hi Jean-Pierre,
The Normal template holds much more than vba. See Normal Template.
Much simpler is to put your code in a separate Global Template.
See Jay Freedman's answer on why you do not want to routinely keep your macros in Normal.dotm. "As a final suggestion, don't routinely save macros in Normal.dotm, precisely because that template is subject to many changes and mishaps are almost inevitable. Macros that you want to keep should be stored in one or more global templates, ones that are stored in the %appdata%\Microsoft\Word\Startup folder and automatically loaded at each startup of Word. The Normal template is handy for "scratchpad" macros but unreliable for anything more important." More on Global Templates.
- kaidoloorCopper ContributorI have the same for some weeks now. My Normal.dotx is on OneDrive, maybe there is a file lock of some kind, when in use by others?
kaidoloor Macros cannot be saved in a .dotx file. While youi might have a Normal.dotx file on your one drive the Normal template from which blank documents are created in Word is a file with the name of Normal.dotm and by default, it is saved in the User Templates folder, the default location for which is
C:\Users\[User Name]\AppData\Roaming\Microsoft\Templates
In place of [User Name] substitute the name with which you log onto the computer, which will appear under
C:\Users
- Charles_KenyonBronze Contributor
The normal template should NEVER be a shared template.
See this feedback.
https://feedbackportal.microsoft.com/feedback/idea/ecf81840-003b-ef11-a297-000d3adace79
Vote and comment.
Currently, any save to the Normal template will shift the identity of the template to a backup file. Subsequent changes made in the template are saved to the backup.