Save as Dialog Box

B

Barth Wilsey

After the user opens a Word 2000 template and completes a form, they press a
command button. The Button_Click subroutine converts the information on the
form's text boxes into the name of the document. I would like to have the
save as dialog box that opens preferentially open to the file where the
template resides. Can you please tell me how to do this.

Here is my present code.

'save this file
With Dialogs(wdDialogFileSaveAs)
.Name = Me.txtLastName.Text & ", " & Me.txtFirstName.Text & " " &
Me.txtMedRec & " " & Format(Date, "mmm d yyyy")
.Show
End With
 
B

Barth Wilsey

Hi Doug,

What code should I use to "save the document in whatever you decide the
folder should be with the filename
that you have created?"

thanks in advance, Barth
 
D

Doug Robbins - Word MVP

Hi Barth,

ActiveDocument.SaveAs "Drive:\Path\" & Me.txtLastName.Text & ", " &
Me.txtFirstName.Text & " " & Me.txtMedRec & " " & Format(Date, "mmm d
yyyy")

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
B

Barth Wilsey

Hi Doug,

Is there any way to not have to hard code the location of "Drive:\Path\"

I would like to use the Word template on various computers and have the
"Drive:\Path\" refer to a folder in the directory where the Word template
resides

Thanks in advance, Barth
 
J

Jonathan West

Barth Wilsey said:
Hi Doug,

Is there any way to not have to hard code the location of "Drive:\Path\"

I would like to use the Word template on various computers and have the
"Drive:\Path\" refer to a folder in the directory where the Word template
resides

This can be done, but how you do it depends a bit on which Word template you
are meaning.

For instance, if you want the path of the template containing the code that
is running, then Application.MacroContainer.Path returns that path.

If you want the folder where user templates are stored, then
Options.DefaultFilePath(wdUserTemplatesPath) returns it.

If you want some other folder, then say which one you want. It is possible
to find ways of identifying most of the important folders in Word using code
of this kind.

(Note that the paths given by the properties I have described don't include
the trailing "\" character. You will have to add that for yourself.)


--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email
 

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