Group:  Microsoft Word ยป microsoft.public.word.mailmerge.fields
Thread: Save As -- Programmatically

Geek News

Save As -- Programmatically
"Rodger" <NoSpam[ at ]hotmail.com> 5/31/2007 2:49:05 PM
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


Re: Save As -- Programmatically
"Peter Jamieson" <pjj[ at ]KillmapSpjjnet.demon.co.uk> 6/2/2007 9:45:55 AM
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

"Rodger" <NoSpam[ at ]hotmail.com> wrote in message
news:%23znQYL5oHHA.2452[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> 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
>
>

Re: Save As -- Programmatically
"rodger" <rodgerdjr[ at ]hotmail.com> 6/2/2007 3:45:57 PM
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


"Peter Jamieson" <pjj[ at ]KillmapSpjjnet.demon.co.uk> wrote in message
news:87F532F2-2CDD-480D-ACB2-F5A01BF5199C[ at ]microsoft.com...
[Quoted Text]
> 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
>
> "Rodger" <NoSpam[ at ]hotmail.com> wrote in message
> news:%23znQYL5oHHA.2452[ at ]TK2MSFTNGP02.phx.gbl...
>> 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
>>
>>
>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net