D
Daniel B. Sigurgeirsson
Hi,
I'm having a slight problem with Office templates (mostly Word templates). A
tool I built for Word (written using Visual C++) helps my users to create
report templates using Word. When the actual report is generated some code is
executed, among other is a line that removes the connection between the
report template and the generated file (it is executed at the end of the
report generation process). This is done to prevent the "Do you want to save
your changes to the xxxtemplate.dot file?" queston to appear when the user
closes the generated report - which seemed to happen too often (not all the
time though). And this works for this particular problem, and for several
reasons I don't want to change this.
However, it imposes another problem. If the user adds special code to the
template, and an additional toolbar to make it easier to execute that special
code, then this will be removed from the generated report. I've managed to
create code that copies (or recreates actually) the toolbars, but I haven't
been able to copy the code (and forms) from the template to the generated
report. Ideally I would like to be able to write code along the lines of:
Dim tmpl as Template
Set tmpl as ActiveDocument.AttachedTemplate
ActiveDocument.VBA.Import( tmpl.Modules("formRecommendations") )
ActiveDocument.VBA.Import( tmpl.Modules("codeModule1") )
ActiveDocument.AttachedTemplate = ""
Of course I realize that this particular code won't work (and does neither
work nor compile), this is more like a pseudocode.
Any ideas?
Best regards,
DanÃel
I'm having a slight problem with Office templates (mostly Word templates). A
tool I built for Word (written using Visual C++) helps my users to create
report templates using Word. When the actual report is generated some code is
executed, among other is a line that removes the connection between the
report template and the generated file (it is executed at the end of the
report generation process). This is done to prevent the "Do you want to save
your changes to the xxxtemplate.dot file?" queston to appear when the user
closes the generated report - which seemed to happen too often (not all the
time though). And this works for this particular problem, and for several
reasons I don't want to change this.
However, it imposes another problem. If the user adds special code to the
template, and an additional toolbar to make it easier to execute that special
code, then this will be removed from the generated report. I've managed to
create code that copies (or recreates actually) the toolbars, but I haven't
been able to copy the code (and forms) from the template to the generated
report. Ideally I would like to be able to write code along the lines of:
Dim tmpl as Template
Set tmpl as ActiveDocument.AttachedTemplate
ActiveDocument.VBA.Import( tmpl.Modules("formRecommendations") )
ActiveDocument.VBA.Import( tmpl.Modules("codeModule1") )
ActiveDocument.AttachedTemplate = ""
Of course I realize that this particular code won't work (and does neither
work nor compile), this is more like a pseudocode.
Any ideas?
Best regards,
DanÃel