none
Macro VBA set AttachedTemplate Error '5947 could not change document template' after opening and closing VBA Editor RRS feed

  • Question

  • Hi, so I've been working with Word Macros recently and I ran into a strange error. So in the document I'm working with, it has a loaded template. I have written VBA code inside the template that changes the ActiveDocument.AttachedTemplate to the Normal.dotm. When testing, I open up the document, select 'Enable macros' and the code runs fine with no errors and does exactly what I want it to do. 

    However, when I was testing again, I opened the document, but before clicking 'Enable macros', I open the VBA Editor (clicking on 'Developer' and then 'Visual Basic') and then immediately close it, without making any changes or anything. After closing the Editor, I then click 'Enable macros', which then gives me the Error '5947 could not change document template'.

    I'm wondering why doing something as simple as just opening the VBA Editor is giving me this error, and how I can fix it?

    Any help would be much appreciated!

    Thanks.

    Monday, July 15, 2019 7:39 PM