Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Wed, 17 May 2006 08:06:56 -0500,    group: microsoft.public.word.vba.userforms        back       


Saving .doc name based upon fields   
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
date: Wed, 17 May 2006 08:06:56 -0500   author:   Eddie Runde

Re: Saving .doc name based upon fields   
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
'_______________________________________

-- 
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
date: Wed, 17 May 2006 10:46:35 -0400   author:   Jean-Guy Marcil NoSpam@LeaveMeAlone

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us