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 / Page Layout / August 2004

Tip: Looking for answers? Try searching our database.

Automatic file name on saving?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Troy Bruder - 19 Aug 2004 18:30 GMT
Hello,

I have a Word template that we use to generate new documents...  Is there a
way to also give this new document its default "save as" file name??

For example..  When we open the DOT, a new document is created..  Within
that document is an automatically calcuated "ID field" (basically just the
date/time formatted as: MMDDYYHHMMSS)...  I want to use that ID field as the
file name when saved so the user doesn't have to type it in and risk a
typo..

Ideas?

Thanks!
Troy
Doug Robbins - 20 Aug 2004 01:02 GMT
ActiveDocument.SaveAs IdField

Need to know what sort of field you are talking about.  If its a formfield,
use

ActiveDocument.SaveAs ActiveDocument.FormFields("IdField").Result

If IdField is the name of a control on a userform, then just the first line
of code should do.  In both cases however, you may want to include the path
to the folder where you want the documents saved.

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Hello,
>
[quoted text clipped - 11 lines]
> Thanks!
> Troy
Troy Bruder - 20 Aug 2004 13:27 GMT
Herein lies the problem...

I need to create a unique ID field...  So I'm using the Date as: MMDDYY
combined with the Time as HHmmss....  If I use the time from the "date
created" field, I don't get the "seconds" which I need to keep things
unique..  So I'm actually using two ID fields..

Ideas for me?

Troy

> ActiveDocument.SaveAs IdField
>
[quoted text clipped - 22 lines]
>> Thanks!
>> Troy
Chad DeMeyer - 20 Aug 2004 15:55 GMT
Troy,

Concatenate the two values.  E.g., Date field is 1st in doc and Time field
is 2nd

sPath = "C:\My Path\"
ActiveDocument.SaveAs sPath & ActiveDocument.Fields(1).Result &
ActiveDocument.Fields(2).Result & ".doc"

Of course, IMHO, using date fields for unique IDs is an extremely perilous
course since the values inserted are dependent on local settings for that
computer, which can vary widely from computer to computer.  You might want
to check out http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.

Regards,
Chad

> Herein lies the problem...
>
[quoted text clipped - 33 lines]
> >> Thanks!
> >> Troy
 
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.