Disable "Save As" menu option?

R

Robert Crandal

How can I prevent a user from choosing the "Save As"
option???

I see that Word 2007 has a macro command that is
named "FileSaveAs". By default, the subroutine looks
like this:

Sub FileSaveAs()
'
' FileSaveAs Macro
' Saves a copy of the document in a separate file
'
Dialogs(wdDialogFileSaveAs).Show

End Sub

If I delete the Dialogs() call in the middle isnt' that
supposed to prevent the Save As dialog box from
appearing???

thankx
 
D

Doug Robbins - Word MVP

If you delete the Dialogs(wdDialogFileSaveAs).Show that will effectively
disable the File>SaveAs command, but it would be better to replace it with a
message informing the user that Saving has been disabled

MsgBox "Saving has been disabled."

However, if the document has not been saved, the Save as dialog will be
displayed by the File>Save command, so you would also need to have a Sub
FileSave() as well.

I suggest that you should think long and hard about going down this path
before one of your users attacks you for preventing them from saving the
document that they have been working on.

And nothing that you do will stop a determined user.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
R

Robert Crandal

I don't really plan to block people from using the "Save As"
menu option. I was just playing with macros in order to gain
a better understanding how they work....

BTW, I deleted the Dialogs(wdDialogFileSaveAs).Show line
of code, yet the Save As dialog box still appears when I
pick the Save As option. Did I do something wrong?
 
D

Doug Robbins - Word MVP

Replace it with a msgbox statement as suggested and that message should
appear. At least, it does here.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

Robert Crandal said:
I don't really plan to block people from using the "Save As"
menu option. I was just playing with macros in order to gain
a better understanding how they work....

BTW, I deleted the Dialogs(wdDialogFileSaveAs).Show line
of code, yet the Save As dialog box still appears when I
pick the Save As option. Did I do something wrong?
 
R

Robert Crandal

It wont work for me at all. Can you show me the steps that
you are using to block the "Save As" dialog from appearing??

My FileSaveAs() macro procedure is completely empty of
any VBA code, yet I am still unable to prevent a Save As
from occurring. I must be doing something wrong....

BTW, I am using Word 2007

Thank you!


Doug Robbins - Word MVP said:
Replace it with a msgbox statement as suggested and that message should
appear. At least, it does here.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
D

Doug Robbins - Word MVP

The following macro created in a module in the Normal.dot template or in a
template that is saved in the Word Startup folder will cause the message to
be displayed and that's it.

Sub FileSaveAs()
MsgBox "Saving has been disabled."
End Sub



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
R

Robert Crandal

Well, I must be doing something wrong, cuz I can't get this to
work at all.

If I load up my Visual Basic project window, I see two different
code sections. One is titled "Normal" and the other is titled "Project".
The "Normal" section has two subfolders: MS Word Objects and
Modules. The Modules are has an item named "NewMacros"
which contains the "FileSaveAs" subroutine.

In the "Project" section, I see the same items as above, except there
is a "References" subfolder.

While we're on this subject, can you please tell me what is the purpose
of the "Normal" section?? I much more accustomed to the project
section of Excel 2007 and I'm basically still a Word 2007 newbie.
So, I'd appreciate any information regarding the Word VBA project
sections....and any more tips on how to get the FileSaveAs() code
to display a message box instead of the normal course of action.

thank you doug and everyone!
 
G

Graham Mayor

Normal refers to the Normal template normal.dotm - the default storage
location for macros
Project accompanied by a name in brackets eg Project(Document1) is the
current document.
There could be other projects if you have more than one document loaded or
you have addins installed.
Maybe http://www.gmayor.com/installing_macro.htm will help?

As for the reason the macro is not working for you, are you actually calling
Save As or are you calling Save. They are separate functions.

Sub FileSave()
MsgBox "Saving has been disabled."
End Sub
Sub FileSaveAs()
MsgBox "Saving As has been disabled."
End Sub

stored in the normal template should confirm it (and prevent you from saving
anything)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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