Consulting

Results 1 to 15 of 15

Thread: Don't let users print a document - covered from all angles...

  1. #1
    VBAX Regular
    Joined
    May 2004
    Location
    Driffield, East Yorkshire, Egnland
    Posts
    69
    Location

    Question Don't let users print a document - covered from all angles...

    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

  2. #2
    VBAX Regular
    Joined
    May 2004
    Location
    Driffield, East Yorkshire, Egnland
    Posts
    69
    Location
    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

  3. #3
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    No solution, but maybe additional problems:
    What if the user disables macros?
    And what about the explorer context menu's Print command?

  4. #4
    VBAX Regular
    Joined
    May 2004
    Location
    Driffield, East Yorkshire, Egnland
    Posts
    69
    Location
    Good point, I never thought of that.

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

    Ad

  5. #5
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    I wish I knew... except for using PDF...

  6. #6
    VBAX Regular
    Joined
    May 2004
    Location
    Driffield, East Yorkshire, Egnland
    Posts
    69
    Location
    Tell me more....

    Ad

  7. #7
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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!

  8. #8
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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??

  9. #9
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  10. #10
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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.

  11. #11
    VBAX Regular JOrzech's Avatar
    Joined
    Jun 2004
    Location
    Upstate New York
    Posts
    83
    Location

    Disable Printer

    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.
    Joanne

  12. #12
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    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.

  13. #13
    VBAX Regular JOrzech's Avatar
    Joined
    Jun 2004
    Location
    Upstate New York
    Posts
    83
    Location
    Well - maybe you could try this:

    [VBA]
    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
    [/VBA]

    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
    Joanne

  14. #14
    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

  15. #15
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Do you have to cover Alt+PrintScreen as well?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •