How do I disable/modify Word 2007 Office Button Print Commands?

Dave Kong
Dave Kong used Ask the Experts™
on
I am creating a ribbon with a print command that will check for fields in the document text and insert a watermark if they exist.  I want to disable the print commands found on the Office Button or modify them to run my field check.  In Word 2003, creating a FilePrint macro with modified code would work, but that does not seem to be working in Word 2007.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave KongSystems Administrator

Author

Commented:
Puppydogbuddy:

Creating my own FilePrint macro was the first thing I tried but did not work.  The article you posted is from MSDN, so I will look it over and try it again (perhaps I missed something critical).  I will try it later today and post the results.  

THANK YOU!
Dave KongSystems Administrator

Author

Commented:
Puppydogbuddy:

I have tried this and had mixed results.  Creating a macro called "FilePrintDefault" was able to modify the Office Button - Print - Quick Print command.  However, my macro called "FilePrint" doesn't affect any of the print commands - the Office Button - Print, the Office Button - Print - Print, the Print button on the Quick Access Toolbar, or print commands within Print Preview - none of these are affected by my macro.

My FilePrint macro was created using the auto method for Word commands.  Any idea why I can't modify FilePrint?
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

I suspect that the FilePrint macro is one of the macros that does not work with the auto method.  Quote from the instructions "It’s important to note that most, but not all, of the Word commands listed in the Macros dialog box can be intercepted using this (auto) method."

I would try adding the macro using the VBA code in an event procedure (see the hyperlink contained in the instructions that says "For more information, see Running Code Based on User Actions (a.k.a. Use Events)."

If you still have trouble getting it to work, post your code from both the auto macro and  the event procedure.


 
ps : your  event procedures will probably be one or more button click events.
Dave KongSystems Administrator

Author

Commented:
Thank you.  I will try this out later today.  I am surprised that creating a FilePrint macro doesn't work, since that is the command used in the example.  
Dave KongSystems Administrator

Author

Commented:
Puppydogbuddy:

I am a bit confused.  The MSDN article refers to a BeforePrint event in Excel, which is what I am looking for, but in Word.  However, When I go to Word and in look at the document-level events, I don't see any command relating to printing.  See my attached screenshot.  In the Object Browser in the Document class I see PrintOut.  I tried a sub called Document_PrintOut, but it didn't seem to do anything.
Word-Document-Events.doc
Mighty-Jack,
ah, I learned something.  If you go to this link:   http://mymsaccessblog.blogspot.com/  and scroll down approximately two pages, you will see a topic called "Macros and Access 2007: What happened to all the extra Macro Actions in Access 2007? "

Access 2007's security enhancements include a distinction between trusted mode and non-trusted mode. Some Macro actions are allowed when your database is running in trusted mode, while some aren't. By default Access only shows you the trusted actions. The hyperlinked article shows you how to see the rest.  As you know, Macro's and VBA code are blocked until the application is Trusted.

See if this clears things up for you.  If not, let me know.  





 
Dave KongSystems Administrator

Author

Commented:
Again, thank you!  I will check the article out.  Glad this has been a learning experience for you too.
Dave KongSystems Administrator

Author

Commented:
After looking at the article and some of the links, I am unclear on how this relates to MS Word.  On the Developer ribber, from the Macro Security command, I have checked trust access to the VBA project model.  In addition, the template I am working on is in a trusted location (see attachment).  Nevertheless, the displayed events remain the same.  Have I missed something critical?
Trust-Location.doc
Mighty-Jack,
I believe I finally have your answer!  I researched the Microsoft Public Word VBA forum and found this link :  
        http://msgroups.net/microsoft.public.word.vba.general/FilePrint-Intercept-2010-is-it-obsolete

Here is all you have to do to make your intercept Macro work the same as in prior versions of Access:
---------------------------------------------------------------------------------------------------------------------------
Ctrl+P is still valid, but it no longer calls FilePrint. Instead, it calls a new command called PrintPreviewAndPrint. If you rename your macro to PrintPreviewAndPrint, Ctrl+P will run it.  
----------------------------------------------------------------------------------------------------------------------------
If you have any further problems, let me know and, if you don't mind, please document the problem with a screenshot instead of attaching application files from MS Office 2007.  I forgot to mention to you that I currently don't have MS Office 2007 installed on my computers.
Dave KongSystems Administrator

Author

Commented:
Puppydogbuddy:

We are getting closer.  I created a PrintPreviewAndPrint macro.  However, I do not see that command listed it the list of Word commands for 2007, which is what we have at our firm.

I now have three macros:  FilePrint, FilePrintDefault, and the new PrintPreviewAndPrint.  I ran some tests and got some enlightening results:

- CTRL + P calls the FilePrint macro

- Both the Quick Print command from the Office button and the Quick Print command on the QAT call the FilePrintDefault macro

- The Print QAT button, the Office - Print and Office - Print - Print commands are not affected by any of the three macros.

My problem is that our more clever attorneys will notice these ways around my checks.  If we can just figure out the correct intercept for those actions in 2007, we are in business!

(I will attach screenshots in the future.)

Mighty-Jack,
If I understood you correctly, you now have the three Word command intercept buttons working.  The two remaining buttons you mentioned are not Word buttons......they are Office buttons.  For those buttons, I believe you can't use the word interceptor method, but you can create a custom command button and use a vba event procedure (e.g. a button click event) to emulate the functionality of the Word buttons.
Dave KongSystems Administrator

Author

Commented:
Puppydogbuddy:

Thanks again!  I checked this out and see how I can create buttons within the document.  Very nice, but it still will not prevent the the wiseguys from using the basic print commands from the Office button.  That is my problem: I need to make this template foolproof so unfinished documents do not get distributed.

I do see in Word 2007 that you can use digital rights management to restrict printing (Office button - Prepare - Restrict Permission).  However, you have to have the permissions to print, and I am not seeing any way in VBA to change the restricted permissions.  If THAT could be done, using DRM might be the way to go.  I must admit I have not used DRM in the past, so perhaps I am missing an important aspect of DRM or not selecting the proper references to control it in VBA.
I did not mean to convey that you had to create a new button.  What I was referring to was the button click event for the Office button.   In effect, write your own intercept routine for the office button.  I have been thinking that maybe we can address the Office Button by its caption....but am currently uncertain how to address the Office Button.  I will research a little furthter and get back to you.
See these links for excellent info and additional links that show how to disable the Office button, and how to customise further to hide the controls behind the Office button.

             http://www.utteraccess.com/forum/Disable-Office-button-Ac-t1309583.html
             
Dave KongSystems Administrator

Author

Commented:
Puppydogbuddy:

Just getting a chance to get back to this.  You've given me a lot to digest.  I will take a look at the materials and let you know the results.
Dave KongSystems Administrator

Author

Commented:
Puppydogbuddy:

Hey, this is great information!  This is what I wanted to learn when we got Office 2007 and never had the time.  I ran through some of the examples and see that when you create your own ribbons from scratch, the Office button strips out most of its commands, which would be perfect for my project.

Thank you so much!  I will tag your 10/29 comment as the accepted solution.
Dave KongSystems Administrator

Author

Commented:
It took some diligence and research to find the answer for me, but Puppydogbuddy was quite tenacious!  This solution has so many potential applications.  I feel like the world of customUI creation is in my hands.
Dave KongSystems Administrator

Author

Commented:
Puppydogbuddy:

I closed this title and accepted your solution.  I was going to go back and print the trio of microsolf articles about customUI, but no longer see the trio of links you had posted  on 10/29.  What happened to them?
I think the links you are looking for are sub-links inside the main link I gave you.  Read through the postings in the main link and you should see the sub-links.  Glad your problem is resolved to your satisfaction.
Dave KongSystems Administrator

Author

Commented:
Thanks.  I just wanted to make sure that the MSDN articles are accessible to anyone who may be reading this discussion later.  They are quite helpful.  

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial