Deactivate function Print

P

Paolo B

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
 
J

Jay Freedman

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

Paolo B

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.

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
 
J

Jay Freedman

Paolo said:
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

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

Jezebel

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

Paolo B

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.

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
 
P

Paolo B

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
 
J

Jezebel

Paolo, the point is, making the macro work won't stop anyone printing your
document. So why waste time on it?
 
P

Paolo B

Paolo, the point is, making the macro work won't stop anyone printing your
document. So why waste time on it?

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
 
J

Jay Freedman

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."
 
J

Jonathan West

Paolo B said:
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?

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

Paolo B

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.
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."
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
 
J

Jay Freedman

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

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

Paolo said:
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.

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
 
P

Paolo B

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

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

Paolo B wrote:
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.

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
 

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