Save As -- Programmatically

R

Rodger

Hello all,

I have an Access Database that I use as my data source. I have forms with a
list of all the Word Documents that the user can view/print. My question is
this . . . . is there a way I can open the Word Document and change the
name of the document. For Example the user is working on a file, lets say
for Company X and they want to print out LetterX.doc, so when they open
LetterABC.doc I would like it to be able to programmatically rename the
letter to CompanyXLetterABC.doc.

In theory I guess I could create a copy of file they are requesting, rename
the file, and then open it up for them. So the merged file would have the
new name. This could also ensure that the Master File is never edited by
accident. Any thoughts?

TIA,
Rodger
 
P

Peter Jamieson

If you use an Access VBA macro to launch the Word Mail Merge Main document,
yes, you could use the Word object model to save the document you opened
under another name. Or you could set up your Mail Merge Main Documents to be
Word templates (.dot) and create new documents based on them.

Typically when you automate Word to do a MailMerge, you have code like

Set objWord = CreateObject("Word.Application")
Set objDoc = appWord.Documents.Open("the pathname of the .doc")

To save the document under a new name, you could use

objDoc.SaveAs Filename:="the new .doc name you want to use"

However, I'd rather not go into more detail than that - it's probably better
to have a look around for good examples using Google or Google Groups.

Peter Jamieson
 
R

rodger

Peter,

Thank you that works perfectly. I am using VBA Code and doing just as you
wrote. Never really thought to use the SaveAs method.

Thanks again.
Rodger
 

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