PDA

View Full Version : Don't let users print a document - covered from all angles...



Adaytay
08-25-2004, 05:49 AM
Hi folks,

I?ve had a request in from a client to block printing of a document, as it contains sensitive information. Now although I can trap the DocumentBeforePrint event in Word and block printing the document by either clicking on the ?Print? icon on the toolbar, or by the user selecting File > Print, there is a hole I need to plug.

If the user goes into PrintPreview mode, and then selects print, the DocumentBeforePrint code does not get run, and the document prints.

Any way round this?

Ad

Adaytay
08-25-2004, 05:54 AM
An additional thought.

Is it possible to actually disable the print / print preview options (ie turn them off) on the menu and toolbar? I think that'd be ideal for my user in this instance...

Cheers,

Ad

Steiner
08-25-2004, 06:28 AM
No solution, but maybe additional problems:
What if the user disables macros?
And what about the explorer context menu's Print command?

Adaytay
08-25-2004, 06:42 AM
Good point, I never thought of that.

Ok. How to completely stop a document being printed - covering ALL angles?

Ad

Steiner
08-25-2004, 06:43 AM
I wish I knew... except for using PDF...

Adaytay
08-25-2004, 06:51 AM
Tell me more.... :D

Ad

fumei
08-25-2004, 08:51 AM
Hi folks. it is very possible to disable ALL printing within a Word document.

In a module, rewrite the various Word commands that print. As in:

Sub FilePrintPreview()
'Overrides the File Print Preview command
MsgBox "This document can not be printed."
End Sub

Sub FilePrint()
'Overrides the File Print command
MsgBox "This document can not be printed."
End Sub

Sub FilePrintDefault()
'Overrides the Print button
MsgBox "This document can not be printed."
End Sub

That takes care of any printing within Word itself. They can not even GET to Print Preview.

OK, now the probem of someone copying the contents to a new document, and then printing THAT one. Solution, do not allow any copying.

Sub EditSelectAll()
'Overrides the Edit Select All command
MsgBox "Sorry, this document does not allow copying of any content."
End Sub

Sub EditCopy()
'Overrides the Edit Copy command
MsgBox "Sorry, this document does not allow copying of any content."
End Sub

Sub Copy()
'Overrides the Edit Copy command
MsgBox "Sorry, this document does not allow copying of any content."
End Sub

Now, the other problem, printing from Windows Explorer. This is tougher. It is going to take some serious API guru to get around it. I am trying but it is, so far, beyond me.

You can password protect the document. Then right clicking in Explorer to get Print, requires a password. So far, so good, Unfortunately, while the password is required to OPEN the file for the API call, once opened, the Explorer API call ignores any internal Word Print commands, and uses its own print command. So this does not work.

BTW: using Explorer Print on a password protected document, DOES require the password, so it is in fact reading through properties of the Word doc. HOWEVER, as stated, it ignores ALL further Word properties and methods. It even ignores an AutoExec sub!

fumei
08-25-2004, 09:23 AM
Oh....hmmm, interesting. While AutoExec does NOT fire when Windows Explorer opens the file (and it MUST open the file), AutoOpen does fire. Which is a little odd.

Now, does anyone know of a way to send a return flag to an existing running Shell command, from Word? The Explorer call is clearly NOT using any of the Word Print commands, as I have disabled all of them. So it must be using a direct process. How can we interfer with that??

TonyJollans
08-25-2004, 10:23 AM
Well,

Not a bad attempt Gerry, but ..

You need to stop Cut as well, which is simple enough, and ..

Selecting manually and then dragging to a new document and printing from there, or ..

Including it in a (new) master document and printing that.

And there's always print screen or opening the document in wordpad.

Basically, you cannot stop a knowledgeable user getting round all of this. You can stop casual printing but not a determined effort - that kind of security isn't available.

I believe there are security options in 2K2 (or 2K3) which may help but I don't think they have any effect if the document is opened in 2K or earlier.

So, sorry, but I don't think it can be done.

fumei
08-25-2004, 12:27 PM
I certainly am not disagreeing. You are correct, it can not be done for all angles. I never suggested it could. My point was that you can disable printing from within a document. You could even disable cut and copy. However, as you correctly point out, you can not stop dragging, or opening it through another app.

JOrzech
08-26-2004, 03:45 PM
Maybe you could run an AutoNew that disables all printers when the document is open and then an AutoClose macro that re-enables them when the document is closed?

I personally don't know how to do that, but that would be the concept.

Steiner
08-30-2004, 06:29 AM
I don't think I'd try that, as tinkering with system resources just to protect a simple document seems like overkill to me.

If it was not my money, I'd perhaps go for Adobe Acrobat. In an pdf you can set what the reader can / can't do, including copy & paste and printing.

JOrzech
08-30-2004, 04:55 PM
Well - maybe you could try this:


CommandBars("File").Controls(11).Delete
CommandBars("Standard").Controls(6).Delete
CustomizationContext = NormalTemplate
FindKey(BuildKeyCode(wdKeyP, wdKeyControl)).Disable
CustomizationContext = NormalTemplate
FindKey(BuildKeyCode(wdKeyF12, wdKeyControl, wdKeyShift)).Disable


Although I'm not sure how you can expect to prohibit printing without "tinkering" with system resources" - because that's exactly what you're asking to do.

Not sure if it will work as you work but give it a try

westconn1
06-09-2005, 07:21 AM
as discussed earlier there are many issues to address, but here is a solution for one

to prevent using the print option in windows explorer or other, that still use word to do the printing.

on document close select all text and change it to hidden font,
change back to normal on opening.

it will still print, but...........
blank page

pete

mdmackillop
06-09-2005, 08:30 AM
Do you have to cover Alt+PrintScreen as well?