Autosave name as field

philbennison

Registered User.
Local time
Today, 07:36
Joined
Nov 10, 2004
Messages
49
Hi all,

(I know this is an access forum, but would the VB script be the same ?)

I have created a word template, which has text form fields in it, and a date field. Is there a bit of code that will save the template with the file name as defined in the field
The fields are date, number, ref, customer and address
therefore when a button is pressed, or the document is closed, it would automatically save as 'ref'+'date'.doc (read only if possible)
i'm sure it would be something to do with the beforeclose command, but am not sure. (If you are feeling realy flash - is there a way of having one button to save,close & exit )

Thanks in advance


Phil
 
the answer

I have collated the infomation from various websites and forums, and place it here for future questions.

Sub FileSaveAs() 'this can be changed to sub filesave()
Dim mydocname
Dim mydocdate
Dim both
With Dialogs(wdDialogFileSaveAs)
mydocname = ActiveDocument.FormFields("text3").Result
mydocdate = ActiveDocument.FormFields("text2").Result
both = mydocname & " & " & mydocdate
.Name = both
.Show
End With
End Sub

Hope it saves someone spending hours trawling through the internet !!!

Phil
 

Users who are viewing this thread

Back
Top Bottom