ROM
asked on
Word Macro's in templates
Word Macro's in templates
Currently we have code that works perfectly when opening the document up. The sub procedure "AutoOpen()" placed in the "ThisDocument" module of the Word Objects part of the project runs and will open a userform. That userform, then uses the ThisDocument command to change the picture of an image control within the document called "imgSpace", using the following code:
ThisDocument.imgSpace.Pict ure = LoadPicture(ImagePath)
This all works fine....that is until the document is then converted to a template. When it is a template, it creates a copy of itself (with references to the original template code), the autoopen() procedure will not run and the references to ThisDocument.imgSpace no longer work.
How can i convert the code to automatically run when the template is opened...and only this template (so not global), and also refer to the control "imgSpace" within the new document based on the template.
Hope this all makes sense, and thank you in advance.
Many thanks
Romolo
Currently we have code that works perfectly when opening the document up. The sub procedure "AutoOpen()" placed in the "ThisDocument" module of the Word Objects part of the project runs and will open a userform. That userform, then uses the ThisDocument command to change the picture of an image control within the document called "imgSpace", using the following code:
ThisDocument.imgSpace.Pict
This all works fine....that is until the document is then converted to a template. When it is a template, it creates a copy of itself (with references to the original template code), the autoopen() procedure will not run and the references to ThisDocument.imgSpace no longer work.
How can i convert the code to automatically run when the template is opened...and only this template (so not global), and also refer to the control "imgSpace" within the new document based on the template.
Hope this all makes sense, and thank you in advance.
Many thanks
Romolo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
cquinn... didnt work im afraid
grahamskan..
yep..worked a treat
many thanks
Romolo
grahamskan..
yep..worked a treat
many thanks
Romolo
Public Sub MAIN()
'Your code goes here
End Sub