Problem with open Templates

N

newboy18

Please help, I have an Access VBA routine that searches
through a query for customer Email Name and Product Type
in that order and sends an email to each customer with a
data sheet for each product attached.
There are 9 different data sheets held as Word templates
and each attachment needs to be edited with some unique
data for that customer.
My routine creates a temp folder and then, for each
customer, depending on the product type opens the
correct .DOT file, edits it, saves it with a new name, and
then closes it, this loops until the next customer is
found, at that stage all the files in the folder are
attached to the email and sent, then the folder is cleared
ready for the next customer.
The problem is that the files can't be attached to an
email if they are still open so I have to keep opening and
closing the templates, is there a better, more efficient
way to do this?
 
C

Charles Kenyon

You don't want to be opening the templates. This isn't how templates are
supposed to be used; thus your problem. Instead, create a new document based
on the template.

Application.Documents.Add Template:="fullname of template including
path"

--
Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://www.addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://www.addbalance.com/usersguide/index.htm>

Word Resources Page
<URL: http://www.addbalance.com/word/wordwebresources.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
N

newboy18

Thanks for your reply Charles,
I have made the changes and they are woring OK.
The routine ends up opening and saving documents about
1500 times and is going to take a while, do you think
there is a better / quicker way to do this?
 

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