Discussion:
How to use the Dialogs object and wdDialogFileSaveAs to actually save a file
(too old to reply)
eholz1
2007-01-15 19:52:07 UTC
Permalink
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
Jay Freedman
2007-01-15 20:53:42 UTC
Permalink
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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Post by 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.
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
eholz1
2007-01-16 17:35:25 UTC
Permalink
Hello Jay et al,

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

ewholz
Post by 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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Post by 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.
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
Loading...