Changing File saveas default In Word

F

firemarshal98

I have created a form in Word and would like to use a couple of the
fields within the form to create the Save as name when the File save
as or the Save as is chosen. I have seen a couple of scripts on how to
change the name in save as dialog box but nothing to choose from a
filed in a form.

I am new to tryiong this in Word and so am just a little confused. I
have created the form as a template and would also like to convert the
format wwhen saved to a .doc format instead of a .dot format.

Any assitance will be greatly appreciated.
 
P

Perry

Example 1)
picking up value of first formfield in the activedocument to represent
filename (path & name)
also using fileformat pointing to a regular Ms Word document, like:

Dim sFileName As String
sFileName = ActiveDocument.FormFields(1).Result
ActiveDocument.SaveAs sFileName, 0

Example 2)
Picks up path from first formfield and filename from second field in the
activedocument
and prepopulates the designated, corresponding dialog controls.

Dim d As Dialog
Set d = Application.Dialogs(wdDialogFileSaveAs)
ChangeFileOpenDirectory ActiveDocument.formfields(1).result
d.Name = activedocument.formfields(2).result
If d.Show Then d.Execute

Example 3)
again, picks up the filename (path & name) of first formfield in
activedocument
and prepopulates the filedialog controls.

Dim d As FileDialog
Set d = Application.FileDialog(msoFileDialogSaveAs)
d.InitialFileName = ActiveDocument.FormFields(1).Result
If d.Show Then d.Execute

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top