How to display Word's File Save As dialog box via VBA?

J

JoAnn

Hi,

I'm creating a FileSaveAs macro to replace Word's default command so I can
perform a customized save as under certain conditions.

To execute Word's default FileSaveAs, I tried entering the code
ActiveDocument.SaveAs -- however, this does not display Word's File Save As
dialog box.

How can I get Word's default Save As behavior (dialog box to prompt them for
name/directory/filetype) via VBA?

Thanks for your help!
 
J

Jay Freedman

JoAnn said:
Hi,

I'm creating a FileSaveAs macro to replace Word's default command so I can
perform a customized save as under certain conditions.

To execute Word's default FileSaveAs, I tried entering the code
ActiveDocument.SaveAs -- however, this does not display Word's File Save As
dialog box.

How can I get Word's default Save As behavior (dialog box to prompt them for
name/directory/filetype) via VBA?

Thanks for your help!

Hi Joann,

You do this:

Dialogs(wdDialogFileSaveAs).Show

or, if you don't want the dialog to actually save the file but just
pass back to you the name the user chose, you do this:

With Dialogs(wdDialogFileSaveAs)
If .Display = -1 Then
myFile = .Name
End If
End With

For more, see http://word.mvps.org/FAQs/MacrosVBA/WordDlgHelp.htm and
http://word.mvps.org/FAQs/MacrosVBA/SetDefFilename.htm.
 

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