Attached template problem

J

jans

Hi,

I've created a Template in word called MergeLetter.dot
In this template I've put some mergefields etc. I've put soms code in
the FileSave command.

When a copy opens, the maindocument AttachedTemplate is
Mergeletter.dot, when I save the maindocument the code from the
FileSave triggers. So that works fine!

When I mailmerge, the merged document AttachedTemplate is still
MergeLetter.dot, till then it's okay. But when I save the merged
document, my code from the FileSave doesn't run, the default filesave
executes not my code!

Help what am I doing wrong...

Janneke
 
C

Cindy Meister -WordMVP-

Hi Jans,
When I mailmerge, the merged document AttachedTemplate is still
MergeLetter.dot, till then it's okay. But when I save the merged
document, my code from the FileSave doesn't run, the default filesave
executes not my code!
The problem comes from the fact that Word doesn't completely attach the
mergeletter.dot. You need to re-attach it, explicitly. In the UI, this
would be Tools/Template and Addins.

In VBA, ActiveDocument.AttachedTemplate = "C:\[Path]\MergeLetter.dot"

If you're using a macro to execute the merge, then put this at the end
of that.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
J

jans

Hi Cindy,

I re-attached the template to the merged document, but still the
FileSave code i've wrote in the template will not trigger in the
merged document.

Any other suggestions?

Thanks

Jans




Cindy Meister -WordMVP- said:
Hi Jans,
When I mailmerge, the merged document AttachedTemplate is still
MergeLetter.dot, till then it's okay. But when I save the merged
document, my code from the FileSave doesn't run, the default filesave
executes not my code!
The problem comes from the fact that Word doesn't completely attach the
mergeletter.dot. You need to re-attach it, explicitly. In the UI, this
would be Tools/Template and Addins.

In VBA, ActiveDocument.AttachedTemplate = "C:\[Path]\MergeLetter.dot"

If you're using a macro to execute the merge, then put this at the end
of that.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
J

jans

Hi Cindy,

I was a little to quick with my posting.

When I merge with a macro...... then I can make it work. First I set
for the merged document the AttachedTemplate to the NormalTemplate and
then I re-attach the merged document to the original Template, then
the FileSave code works.

OriginalTemp = ActiveDocument.AttachedTemplate.Path &
Application.PathSeparator & ActiveDocument.AttachedTemplate.Name
ActiveDocument.AttachedTemplate = NormalTemplate
ActiveDocument.AttachedTemplate = OriginalTemp

But now I have to intercept a lot of Word commands (ways to merge), so
that the merged document will be re-attached.

Isn't it a little funny that I have to re-attach this document like
this?
Is this the only way to do this? I think i'm missing the real problem
here....
Any suggestions?

Thanks

Janneke
 
C

Cindy Meister -WordMVP-

Hi Jans,
Isn't it a little funny that I have to re-attach this document like
this?
Is this the only way to do this? I think i'm missing the real problem
here....
Yes, yes... and no. Word didn't even attach the template from the main
merge doc in earlier versions of Word. And when it finally did, somehow
the attachment is incomplete. Perhaps because the attachment is
occurring sometime during the merge process, when the result document
isn't complete, yet, would be my guess.

You just have to train your users to use "your way". Which version of
Word are you targetting.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top