MS Office Forum / Word / Programming / November 2004
Deactivate function Print
|
|
Thread rating:  |
Paolo B - 04 Nov 2004 11:34 GMT I have word 2003.
I'm looking for a Macro that is able to deactivate (disallow) the function Print.
So when anyone open my document he could not print it.
Thanks,Paolo B
Jay Freedman - 04 Nov 2004 20:35 GMT Hi Paolo,
To answer your question literally, you can just write two empty macros:
Public Sub FilePrint End Sub
Public Sub FilePrintDefault End Sub
The first one intercepts the File > Print menu item and does nothing; the second one intercepts the print button on the toolbar and does nothing.
But if the user's machine has the macro security level (Tools > Macro > Security) set to High, your macros won't work, and there's nothing you can do about that. And even if you somehow managed to prevent Word from printing the document, the user can still take screen shots with Alt+PrintScreen and print those. Not even PDF format, which can lock out the print function, could prevent that. The only document that users can't print is one that you never let them see.
 Signature Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org
> I have word 2003. > [quoted text clipped - 4 lines] > > Thanks,Paolo B Paolo B - 04 Nov 2004 21:04 GMT > To answer your question literally, you can just write two empty macros: > [quoted text clipped - 6 lines] > The first one intercepts the File > Print menu item and does nothing; the > second one intercepts the print button on the toolbar and does nothing. Hi Jay,
thanks, but I if write on the VBA only
Public Sub FilePrint End Sub
or
Public Sub FilePrintDefault End Sub
and then I play the macro, I can print! Where I'm wrong?
PaoloB
Jay Freedman - 04 Nov 2004 21:45 GMT >> To answer your question literally, you can just write two empty >> macros: [quoted text clipped - 24 lines] > > PaoloB I'll guess that you may have your macro security level set to High, as I mentioned in my other post. That means that no macros can run, so they aren't intercepting the built-in commands.
The other question is, where did you store the macros? For testing purposes, they should be in a new module in one of these places: (1) the document itself, (2) the template that the document is based on, or (3) Normal.dot. For distribution to others, they must be stored in the document. If the macros are somewhere else, they may not run even though the macro security level is Medium or Low.
 Signature Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org
Paolo B - 05 Nov 2004 09:33 GMT > I'll guess that you may have your macro security level set to High, as I > mentioned in my other post. That means that no macros can run, so they [quoted text clipped - 6 lines] > macros are somewhere else, they may not run even though the macro security > level is Medium or Low. Hi Jay,
it doesn't run. my macro securitu level is Medium. The problem could be where i store the macro, tell me, please, if is ok or wrong VBA (ALT+F11) > Normal > Microsoft Word Object > ThisDocument PaoloB
Jezebel - 05 Nov 2004 10:07 GMT Paolo, don't bother. It doesn't solve your problem.
> > I'll guess that you may have your macro security level set to High, as I > > mentioned in my other post. That means that no macros can run, so they [quoted text clipped - 16 lines] > VBA (ALT+F11) > Normal > Microsoft Word Object > ThisDocument > PaoloB Paolo B - 05 Nov 2004 10:46 GMT > Paolo, don't bother. It doesn't solve your problem. That is my problem, ok? If you don't won't help me doesn't matter, I hope some one will replay about:
my macro securitu level is Medium. The problem could be where i store the macro, tell me, please, if is ok or wrong VBA (ALT+F11) > Normal > Microsoft Word Object > ThisDocument
PaoloB
Jezebel - 05 Nov 2004 11:45 GMT Paolo, the point is, making the macro work won't stop anyone printing your document. So why waste time on it?
> > Paolo, don't bother. It doesn't solve your problem. > [quoted text clipped - 7 lines] > > PaoloB Paolo B - 05 Nov 2004 14:08 GMT > Paolo, the point is, making the macro work won't stop anyone printing your > document. So why waste time on it?
> > I hope some one will replay about: > > my macro securitu level is Medium. > > The problem could be where i store the macro, tell me, please, if is ok or > > wrong > > VBA (ALT+F11) > Normal > Microsoft Word Object > ThisDocument The poin is that the Word document I'll send to people that are quite dumm on the pc (they dont know about, macro, Windows Explorer: right-click etc. etc.) So if they see that the print botton doesn't work thay dond go over. At the same time they use word and not PDF.
So please where I have to store? in VBA (ALT+F11) > Normal > Microsoft Word Object > ThisDocument?
PaoloB
Jonathan West - 06 Nov 2004 15:58 GMT >> Paolo, the point is, making the macro work won't stop anyone printing >> your [quoted text clipped - 15 lines] > Word > Object > ThisDocument? Paolo,
This situation is like this
1. Most people who are dumb about PCs and who have Word, have their macro security setting on High, because this is how Word is set up by default all all versions of Word since Word 2000.
2. If you get your blank FilePrint macros to work on your machine, they won't work on somebody else's machine because of the security settings
3. Somebody who isn't dumb about Word will know how to set the security settings to get rid of your macros or to stop them running.
4. Therefore, there is no way you can achieve what you are wanting with a Word document. Word is not designed to be able to do what you are trying to do.
Every so often, somebody posts here with what they believe to be a solution to this problem. Invariably, when they produce a document that has the security feature, it takes me no more than a minute or two to break the security. Usually less time than that.
I have been using Word for nearly 20 years, and I can tell you that in all that time, nobody has demonstrated a way of creating a non-printing document that actually worked.
 Signature Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup
Jay Freedman - 05 Nov 2004 21:17 GMT Hi Paolo,
Although I think what you did should have worked for your test, you shouldn't have it in Normal if you want to have it work for other users. Instead, do this:
Open the document that you want to protect from printing.
Alt+F11 > Project (Document name) where "Document name" is the name of the open document
Then on the menu in the macro editor, Insert > Module. This will create a folder named Modules below the Microsoft Word Objects icon, and it will contain a Module1 icon. The title bar at the top of the editor should say "Microsoft Visual Basic - Document name - [Module1 (Code)]" and the bid window on the right should be empty (but if it says "Option Explicit" you can leave that). Put the two macros there (and remove them from Normal). Click File > Save. Then go to the main Word window and click File > Print. Nothing should happen -- no dialog, no printing.
Another thing you could do is put a message on the screen when these macros run. In each macro, put this line between the Sub and End Sub lines:
MessageBox "Printing of this document is not permitted."
 Signature Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org
>> I'll guess that you may have your macro security level set to High, >> as I mentioned in my other post. That means that no macros can run, [quoted text clipped - 15 lines] > VBA (ALT+F11) > Normal > Microsoft Word Object > ThisDocument > PaoloB Paolo B - 07 Nov 2004 13:08 GMT Hi Jay,
that was the answer that I was looking for, It works, thanks.
The only think that I didn't found is when you said: "(and remove them from Normal)". Where are they?
Last stupid question. If the person that recive the document by me has the macro security level in Medium or Low, in any case, when he open the document see a dialog mask with "do you want active the macro?" or with a message something like this?
PoaloB
> Although I think what you did should have worked for your test, you > shouldn't have it in Normal if you want to have it work for other users. [quoted text clipped - 18 lines] > > MessageBox "Printing of this document is not permitted."
> >> I'll guess that you may have your macro security level set to High, > >> as I mentioned in my other post. That means that no macros can run, [quoted text clipped - 15 lines] > > VBA (ALT+F11) > Normal > Microsoft Word Object > ThisDocument > > PaoloB Jay Freedman - 07 Nov 2004 22:03 GMT Hi Paolo,
You said you went to Alt+F11 > Normal > Microsoft Word Object > ThisDocument to insert the macros the first time. If they're still there, you can delete them -- they don't belong there.
If the person receiving your document has the security level set to Low, they won't see any message. The macros will just work. (But that would be stupid on their part, because *any* macro will just work, and it could be a virus.)
If the person has the level set to Medium, which we recommend, then there will be a message box every time they open any document that contains a macro. The box has three buttons: "Disable macros", "Enable macros", and "Cancel". If they click "Disable", the document will open but the macros won't work. If they click "Enable", the document will open and the macros will work. Finally, if they click "Cancel", the document won't open.
If the person has the level set to High, there will be no message box, and the macros won't work.
-- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org
>Hi Jay, > [quoted text clipped - 53 lines] >> > VBA (ALT+F11) > Normal > Microsoft Word Object > ThisDocument >> > PaoloB Paolo B - 07 Nov 2004 23:25 GMT Hi Jay,
thanks, thanks for your kind and sharp answer, it helped me a lot.
Thank you,
PaoloB
> You said you went to Alt+F11 > Normal > Microsoft Word Object > > ThisDocument to insert the macros the first time. If they're still [quoted text clipped - 78 lines] > >> > VBA (ALT+F11) > Normal > Microsoft Word Object > ThisDocument > >> > PaoloB Jezebel - 05 Nov 2004 06:00 GMT The user can still print the document by displaying the Macros dialog, selecting Word Commands from the 'Macros In' list, then selecting FilePrint from the drop down. This method always runs the built-in command, regardless of any macros.
They can also do it through Windows Explorer: right-click the file and select 'Print' -- this also ignores any macros.
A stronger, but not failsafe, method is to create a PDF and set the security to prevent printing.
> Hi Paolo, > [quoted text clipped - 25 lines] > > > > Thanks,Paolo B
|
|
|