TonyJollans
09-23-2005, 10:44 AM
Following on from another thread I found out one or two things I didn't know about AutoExec macros so I have read up and experimented. You probably all know this but an AutoExec in a global Template runs when the Template is loaded.
While playing with this I did the following:
Renamed Normal.dot so that I got a brand new clean one - this isn't necessary, it just shows that nothing I have in Normal is interfering with anything.
Removed all my existing global Templates - again just so they didn't interfere.
Created two new blank global templates in my startup folder - Temp1.dot and Temp2.dot
Closed and opened Word
Opened one of the templates, Temp2, for editing and added an AutoExec macro
Sub AutoExec
Msgbox ThisDocument.Name
End Sub
Closed Word - when prompted to save changes to Temp2, replied Yes
Opened Word - saw message box "Temp2.dot" as expected
Opened the other template, Temp1, for editing and added the same simple Autoexec macro to it.
Closed Word - when prompted to save changes to Temp1, replied Yes
Was then prompted to save changes to Temp2, even though I hadn't opened it for editing.
Replied No
Opened Word and saw two message boxes "Temp1.dot" and "Temp2.dot" - as expected.
Next I repeated the above, except that in the next to last step, I replied Yes to save changes to Temp2
Opened Word again. This time I only saw one message box, "Temp1.dot".
The macro in Temp2.dot was completely disabled - the text was there in the module in the VBE but the macro was not - it didn't autorun, it wasn't available via ALt+F8, etc. I could add new procedures to the module and they all worked OK, but the AutoExec just, for all practical purposes, wasn't there.
Now, I don't know any way to so totally disable a macro. With a lot of messing about, I can make it come back but I'm not entirely certain of a consistent set of steps to do it. But what has happened?
Is this something else I don't know that I really should - or is there something funny going on here?
While playing with this I did the following:
Renamed Normal.dot so that I got a brand new clean one - this isn't necessary, it just shows that nothing I have in Normal is interfering with anything.
Removed all my existing global Templates - again just so they didn't interfere.
Created two new blank global templates in my startup folder - Temp1.dot and Temp2.dot
Closed and opened Word
Opened one of the templates, Temp2, for editing and added an AutoExec macro
Sub AutoExec
Msgbox ThisDocument.Name
End Sub
Closed Word - when prompted to save changes to Temp2, replied Yes
Opened Word - saw message box "Temp2.dot" as expected
Opened the other template, Temp1, for editing and added the same simple Autoexec macro to it.
Closed Word - when prompted to save changes to Temp1, replied Yes
Was then prompted to save changes to Temp2, even though I hadn't opened it for editing.
Replied No
Opened Word and saw two message boxes "Temp1.dot" and "Temp2.dot" - as expected.
Next I repeated the above, except that in the next to last step, I replied Yes to save changes to Temp2
Opened Word again. This time I only saw one message box, "Temp1.dot".
The macro in Temp2.dot was completely disabled - the text was there in the module in the VBE but the macro was not - it didn't autorun, it wasn't available via ALt+F8, etc. I could add new procedures to the module and they all worked OK, but the AutoExec just, for all practical purposes, wasn't there.
Now, I don't know any way to so totally disable a macro. With a lot of messing about, I can make it come back but I'm not entirely certain of a consistent set of steps to do it. But what has happened?
Is this something else I don't know that I really should - or is there something funny going on here?