Change name of active document with out saving it.

B

brotherescott

I have a macro that opens up a word doc using a template. I rename the
current "Document 1" that it automatically gets named with something
like "2006.09.08 Phone Conv. ". I want this text to always be there so
I just add in somthing unique at the end when I do a save as to a
location that I want to put it. Here is where my problem comes in. When
I do the ActiveDocument.SaveAs to give it this starter file name it
actually saves a copy in what ever directory is current. When I do a
saves as and give it the final name in the directory I want it to be in
it saves fine but I go back to where ever the current path was when the
VBA code did the ActiveDocument.SaveAs and I see a copy there of the
original document.
Basically, how can I rename the active document with out saving it?
ActiveDocument.Name="test.doc" does not work.

Documents.Add Template:= _
"C:\Templates\Phone Conversation.dot" _
, NewTemplate:=False, DocumentType:=0
ActiveDocument.SaveAs FileName:=Format(Now(), "yyyy.mm.dd") & " Phone
Conv- "

Thanks
Scott
 
J

Jay Freedman

The *only* way to change the name of a document is to save it to disk. Until
the document has been saved, it doesn't really have a name (the "Document 1"
is a dummy placeholder).

What you can do is to change what Word suggests as the default name in the
SaveAs dialog, by placing text in the Title property. See
http://word.mvps.org/faqs/macrosvba/SetDefFilename.htm for sample code.

You may also be interested in
http://word.mvps.org/FAQs/MacrosVBA/ChangeSaveAsPath.htm for setting the
folder in the dialog.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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