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 / May 2006

Tip: Looking for answers? Try searching our database.

Saving .doc name based upon fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eddie Runde - 17 May 2006 14:06 GMT
I would like to have the name of new documents (based upon a particular
template) to be automatically generated based upon fields within the
document.
    For example:  Name the document based upon a client's name and
    date of service.
Can this be done?  If so, how?

Thanks
-- EWR
Jean-Guy Marcil - 17 May 2006 15:46 GMT
Eddie Runde was telling us:
Eddie Runde nous racontait que :

> I would like to have the name of new documents (based upon a
> particular template) to be automatically generated based upon fields
> within the document.
> For example:  Name the document based upon a client's name and
> date of service.
> Can this be done?  If so, how?

Yes, but it is a bit more involved than you might think.

What if the user types illegal characters in the name or date fields?

When will the save action occur?
   When the document is first created?
   When the document is closed?
   When the user wants to save?

What if the user creates a document based on that template, but then wants
to close without saving?
If the whole thing is to be automatic, which folder should be sued to store
the saved document?
Are we talking about a document protected for forms?

In any case, here is some code to get you going:

'_______________________________________
Dim myFileName As String

With ActiveDocument.FormFields
   myFileName = .Item("NameClient").Result _
       & "_" & .Item("DateCLient").Result
End With

With Dialogs(wdDialogFileSaveAs)
   .Name = myFileName
   .Show
End With
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

 
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.