Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Change name of active document with out saving it.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
brotherescott@yahoo.com - 08 Sep 2006 17:55 GMT
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
Jay Freedman - 08 Sep 2006 20:55 GMT
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.

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> 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
[quoted text clipped - 18 lines]
> Thanks
> Scott

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.