How to use the Dialogs object and wdDialogFileSaveAs to actually save a file

E

eholz1

Hello Word Group,

I thought the above task would be easy. Wrong. (at least not for
me!).
No prob using activedocument.save or saveas.

I would like to present the user with a dialog window, so the user can
save a file (in *.doc format only)
but be able to name it as the user desires, and put it where the user
desires.

I would like to do this from vba.

I have the following code which opens (show) a dialog window, but it
opens to the *.dot filetype,
I can navigate to "C:\My documents", but the file is never saved.

code is below:

Sub ShowSaveAsDialog()
Dim dlgSaveAs As Object
' Dim ePath As String

'ePath = "C:\My Documents\"
Set dlgSaveAs = Dialogs(wdDialogFileSaveAs)
dlgSaveAs.Show

End Sub
(i have tried dlgSaveAs.Execute - it errors out.

I want this code to be in a module in a custom template (as opposed to
Normal.dot),

any tips on this one???

thanks

ewholz
 
J

Jay Freedman

If you're testing the macro by running it while the template is the "current
document", that's the problem. Word "knows" when you're saving a template,
and it will force the SaveAs dialog to the User Templates folder. It also
won't let you save a template as a .doc file -- a template is always a
template, as far as Word is concerned.

Try running the macro while a plain document is active, and it should behave
the way you expect.

For some background and other help, see
http://www.word.mvps.org/FAQs/MacrosVBA/WordDlgHelp.htm,
http://www.word.mvps.org/FAQs/MacrosVBA/ChangeSaveAsPath.htm, and
http://www.word.mvps.org/FAQs/MacrosVBA/SetDefFilename.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
E

eholz1

Hello Jay et al,

I got it sorted out (at least for the time being). Thanks for the
information and the links!

ewholz
 

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