Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent "Save As" in Word

Status
Not open for further replies.

vbajock

Programmer
Jun 8, 2001
1,921
US
For security reasons, I want to prevent users from doing a "Save As" in a Word Document that I will display Read Only via Access VBA code for printing. Is there a setting in Word that I can set in the template to achieve this, and if not, how can I do it thru code otherwise?

Thanks in advance for your help!
 
OK, nevermind, found "Commandbars" object, be nice if I could find a list of all the control names...
 
For security reasons,"

This is simply not truly possible. Yes you can do some things to slow down people who do not know Word. There is NOTHING you can do to stop people who really do know Word. Basically, if you can see the document...you can get a copy of it. Word has not ever been, nor is it now, secure.

The easiest way to prevent a direct SaveAs is to write a new Sub for it.
Code:
Sub FileSaveAs()
   Msgbox "File SaveAs is disabled."
End Sub
The message will be displayed if someone tries to do a SaveAs.

But again, this is not secure. No Word document is secure.

I am curious though. Using Commandbars to do....what?

faq219-2884

Gerry
My paintings and sculpture
 
Furthermore, how do you expect to prevent users to copy/paste the displayed text, to scan and convert to text the printed material, to print to a text file, to ... ?
 
You could instead try to write some code that will
1. print the doc to a pdf with security set to prohibit all but printing (i.e. prohibit copying, saving/save as...)
2. display the pdf rather than the doc

Would that be feasible?

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Certainly using PDF is a bit more "secure" than an actual Word document. You can get PDF files very tight.

As PHV mentions (and these are only a few), there are many ways to get a copy of a Word document. Yes, there are ways to block things, like SaveAs, or the Print dialog (so you can not choose print-to-file)...but all of them can be circumvented.

The bottom line really is, if you can get a Word document on-screen (i.e. open for viewing), you can get its contents. Yes, you can prevent the "average" user from getting a copy, but there simply is no way to prevent a knowledgeable user from doing it.

faq219-2884

Gerry
My paintings and sculpture
 
Actaully, Windows Rights Management Services can lock down a Word document pretty comprehensively ... but it is probably rather too heavyweight a solution here
 
Ummmm, true, but you are making rather expansive assumptions.

1. you have to HAVE Windows Rights Management Services (Server 2003 is required). I work in a government organization with 26,000 users...we do NOT have RMS.

2. you are using a RMS-enabled application or browser (with updated API for those clients)

faq219-2884

Gerry
My paintings and sculpture
 
Actually, the client in this case would probably be interested in the RMS, I'll look into it, thanks.

The Commandbars code allowed me to disable menu options:

app.Activate 'Open the Document
app.Documents.Open FileName:=GetDestinationFile(), ReadOnly:=True
app.CommandBars("Menu Bar").Controls("&File").Controls("Save &As...").Enabled = False

app.CommandBars("Menu Bar").Controls("&File").Controls("Save").Enabled = False
app.CommandBars("Menu Bar").Controls("&View").Controls("Toolbars").Enabled = False

CustomizationContext = app.ActiveDocument.AttachedTemplate

For Each CommandShortcuts In KeysBoundTo(wdKeyCategoryCommand, "SaveAs")
CommandShortcuts.Disable
Next CommandShortcuts
For Each CommandShortcuts In KeysBoundTo(wdKeyCategoryCommand, "Save")
CommandShortcuts.Disable
Next CommandShortcuts

This locks it down well enough to prevent low-skill level people from copying the document, not perfect, but better than wide open.
 
Also, thanks for the tip on the PDF, that sounds like the way to go, I am going to play around with that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top