Forum Discussion

jpgeets's avatar
jpgeets
Copper Contributor
Jun 08, 2024

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

    • jpgeets's avatar
      jpgeets
      Copper Contributor

      Charles_Kenyon 

       

      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_Kenyon's avatar
        Charles_Kenyon
        Bronze Contributor

        jpgeets 

        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.

  • stefanknoob's avatar
    stefanknoob
    Copper Contributor

    I there, I have exactly the same problem but do not see any solution anywhere ...

    Regards, Stefan

    • jpgeets's avatar
      jpgeets
      Copper Contributor

      stefanknoob

       

      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 me

       

      Best regards,
      Jean-Pierre

  • kaidoloor's avatar
    kaidoloor
    Copper Contributor
    I 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?

Resources