D
Daníel B. Sigurgeirsson
Hi everyone,
I have a problem, and I'm hoping someone can help me solve it
My
scenario looks like this:
1. I have a Word document template that contains several macros. This
document contains (among other things) some combo boxes a command button,
and an event handler is attached to this button. The code for this event
handler is stored in the document template.
2. The end user creates a document based on this document template. After
the document has been created he must select certain values from the combo
boxes and then press the command button to confirm his selection. Now he can
save the result document.
3. For reasons that are beyond this issue, the code that is executed when
the document is initially generated from the document template, must contain
the line
ActiveDocument.AttachedTemplate = ""
but this breaks the behaviour descibed in steps 1 and 2, since it requires
the document template and the code and event handler that is defined there.
What I would like to do is to write some code that during the creation of
the document will copy the relevant event handler and all code it requires
to the end document, and then detach the document template from the
document. So far I haven't had much luck with this. It appears that the
event handler must be stored in the "ThisDocument" section and not in a
separate code module. Is this correct? How can I programmatically add code
to this section?
With best regards,
Daniel
I have a problem, and I'm hoping someone can help me solve it
scenario looks like this:
1. I have a Word document template that contains several macros. This
document contains (among other things) some combo boxes a command button,
and an event handler is attached to this button. The code for this event
handler is stored in the document template.
2. The end user creates a document based on this document template. After
the document has been created he must select certain values from the combo
boxes and then press the command button to confirm his selection. Now he can
save the result document.
3. For reasons that are beyond this issue, the code that is executed when
the document is initially generated from the document template, must contain
the line
ActiveDocument.AttachedTemplate = ""
but this breaks the behaviour descibed in steps 1 and 2, since it requires
the document template and the code and event handler that is defined there.
What I would like to do is to write some code that during the creation of
the document will copy the relevant event handler and all code it requires
to the end document, and then detach the document template from the
document. So far I haven't had much luck with this. It appears that the
event handler must be stored in the "ThisDocument" section and not in a
separate code module. Is this correct? How can I programmatically add code
to this section?
With best regards,
Daniel