Obtaining "Save as type" (user input) value from Save As Dialog Bo

G

Graig

I want to ensure that the user does NOT select any other "Save as type"
other than "Word Document *.doc", to ensure that the macros are
retained in the file. So..........

I am displaying the Save As Dialog Box.

I thought I would interpret what "Save as type" the user has selected, and in
the case of them selecting anything other than "Word Document *.doc" generate
an error message box, and then NOT execute the Save dialog.

I thought that the property "Dialogs(wdDialogFileSaveAs).Format" would
return the user selection, but it does not.

What property or method can I use to obtain the user selected "Save as type"?
Or - if there's a better way to ensure that an original Word document is
always
saved as a "Word Document *.doc" regardless of name and/or location, I
would enjoy hearing about those options as well.

Thanks in advance!
 
J

Jezebel

I assume your approach is to write a macros called FileSave and FileSaveAs
to trap the user's save requests. (You need FileSave for the first time the
user saves the documents.)

Here are two approaches you could use --

1. Display the dialog instead of showing it. This collects the user input
but doesn't act on it. Then execute your own Save instruction with the name
provided by the user and ignoring their file type selection --

with Dialogs(wdDialogFileSaveAs)
if .display = -1 then
activedocument.SaveAs FileName = .Name, Format:=wdFormatDocument
end if
end with

2. Create a form and add a commondialog control. Use that to select the
filename, without giving the user any type option. You don't have to show
the form itself to use the dialogcontrol --

With New frmMyForm
with .CommonDialog1
.CancelError = False
.DialogTitle = ...
: [quite a few properties you might want to set]
.ShowSave
If len(.FileName) > 0 then
activedocument.SaveAs FileName = .FileName,
Format:=wdFormatDocument
end if
end with
end with

The second option is maybe better in that it doesn't mislead the user.
 
G

Graig

Thanks for the reply.

I was doing option 1 (below), but wanted to notify the user that the
file can only be saved as a Word Document, if, and only if they
selected another save type.

Option 2 provides an approach to constraining the "save as type".

Still curious about how to retrieve the "save as type" value selected
by the user on the Save Dialog Box. Any thoughts on that?



Jezebel said:
I assume your approach is to write a macros called FileSave and FileSaveAs
to trap the user's save requests. (You need FileSave for the first time the
user saves the documents.)

Here are two approaches you could use --

1. Display the dialog instead of showing it. This collects the user input
but doesn't act on it. Then execute your own Save instruction with the name
provided by the user and ignoring their file type selection --

with Dialogs(wdDialogFileSaveAs)
if .display = -1 then
activedocument.SaveAs FileName = .Name, Format:=wdFormatDocument
end if
end with

2. Create a form and add a commondialog control. Use that to select the
filename, without giving the user any type option. You don't have to show
the form itself to use the dialogcontrol --

With New frmMyForm
with .CommonDialog1
.CancelError = False
.DialogTitle = ...
: [quite a few properties you might want to set]
.ShowSave
If len(.FileName) > 0 then
activedocument.SaveAs FileName = .FileName,
Format:=wdFormatDocument
end if
end with
end with

The second option is maybe better in that it doesn't mislead the user.





Graig said:
I want to ensure that the user does NOT select any other "Save as type"
other than "Word Document *.doc", to ensure that the macros are
retained in the file. So..........

I am displaying the Save As Dialog Box.

I thought I would interpret what "Save as type" the user has selected, and in
the case of them selecting anything other than "Word Document *.doc" generate
an error message box, and then NOT execute the Save dialog.

I thought that the property "Dialogs(wdDialogFileSaveAs).Format" would
return the user selection, but it does not.

What property or method can I use to obtain the user selected "Save as type"?
Or - if there's a better way to ensure that an original Word document is
always
saved as a "Word Document *.doc" regardless of name and/or location, I
would enjoy hearing about those options as well.

Thanks in advance!
 
G

Graig

Thanks for the reply.

I was doing option 1 (below), but wanted to notify the user that the
file can only be saved as a Word Document, if, and only if they
selected another save type.

Option 2 provides an approach to constraining the "save as type".

Still curious about how to retrieve the "save as type" value selected
by the user on the Save Dialog Box. Any thoughts on that?



Jezebel said:
I assume your approach is to write a macros called FileSave and FileSaveAs
to trap the user's save requests. (You need FileSave for the first time the
user saves the documents.)

Here are two approaches you could use --

1. Display the dialog instead of showing it. This collects the user input
but doesn't act on it. Then execute your own Save instruction with the name
provided by the user and ignoring their file type selection --

with Dialogs(wdDialogFileSaveAs)
if .display = -1 then
activedocument.SaveAs FileName = .Name, Format:=wdFormatDocument
end if
end with

2. Create a form and add a commondialog control. Use that to select the
filename, without giving the user any type option. You don't have to show
the form itself to use the dialogcontrol --

With New frmMyForm
with .CommonDialog1
.CancelError = False
.DialogTitle = ...
: [quite a few properties you might want to set]
.ShowSave
If len(.FileName) > 0 then
activedocument.SaveAs FileName = .FileName,
Format:=wdFormatDocument
end if
end with
end with

The second option is maybe better in that it doesn't mislead the user.





Graig said:
I want to ensure that the user does NOT select any other "Save as type"
other than "Word Document *.doc", to ensure that the macros are
retained in the file. So..........

I am displaying the Save As Dialog Box.

I thought I would interpret what "Save as type" the user has selected, and in
the case of them selecting anything other than "Word Document *.doc" generate
an error message box, and then NOT execute the Save dialog.

I thought that the property "Dialogs(wdDialogFileSaveAs).Format" would
return the user selection, but it does not.

What property or method can I use to obtain the user selected "Save as type"?
Or - if there's a better way to ensure that an original Word document is
always
saved as a "Word Document *.doc" regardless of name and/or location, I
would enjoy hearing about those options as well.

Thanks in advance!
 
J

Jezebel

Dialogs(wdDialogFileSaveAs).Format

Check the Help topic "Built-in dialog box argument lists" for the full list.


Graig said:
Thanks for the reply.

I was doing option 1 (below), but wanted to notify the user that the
file can only be saved as a Word Document, if, and only if they
selected another save type.

Option 2 provides an approach to constraining the "save as type".

Still curious about how to retrieve the "save as type" value selected
by the user on the Save Dialog Box. Any thoughts on that?



Jezebel said:
I assume your approach is to write a macros called FileSave and FileSaveAs
to trap the user's save requests. (You need FileSave for the first time the
user saves the documents.)

Here are two approaches you could use --

1. Display the dialog instead of showing it. This collects the user input
but doesn't act on it. Then execute your own Save instruction with the name
provided by the user and ignoring their file type selection --

with Dialogs(wdDialogFileSaveAs)
if .display = -1 then
activedocument.SaveAs FileName = .Name, Format:=wdFormatDocument
end if
end with

2. Create a form and add a commondialog control. Use that to select the
filename, without giving the user any type option. You don't have to show
the form itself to use the dialogcontrol --

With New frmMyForm
with .CommonDialog1
.CancelError = False
.DialogTitle = ...
: [quite a few properties you might want to set]
.ShowSave
If len(.FileName) > 0 then
activedocument.SaveAs FileName = .FileName,
Format:=wdFormatDocument
end if
end with
end with

The second option is maybe better in that it doesn't mislead the user.





Graig said:
I want to ensure that the user does NOT select any other "Save as type"
other than "Word Document *.doc", to ensure that the macros are
retained in the file. So..........

I am displaying the Save As Dialog Box.

I thought I would interpret what "Save as type" the user has selected,
and
in
the case of them selecting anything other than "Word Document *.doc" generate
an error message box, and then NOT execute the Save dialog.

I thought that the property "Dialogs(wdDialogFileSaveAs).Format" would
return the user selection, but it does not.

What property or method can I use to obtain the user selected "Save as type"?
Or - if there's a better way to ensure that an original Word document is
always
saved as a "Word Document *.doc" regardless of name and/or location, I
would enjoy hearing about those options as well.

Thanks in advance!
 

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