Outlook Print Event

M

Mark Wilson

While Word 2007 has a DocumentBeforePrint event, Outlook 2007 seems to have
nothing. I need to implement a print confirmation dialog for Outlook. While
it is possible to repurpose FilePrint by adding some code to CustomUI.xml,

<commands>
<command idMso="FilePrint" onAction="MyPrintConfirmation" />
</commands>

....this will only trap Print commands that the user activates via the
Ribbon. If the user uses a keyboard shortcut like <CTRL P> then
MyPrintConfirmation is not executed.

With the deprecation of Exchange Client Extentions for the next release of
Outlook, this seems to be an event that previously could be captured via
IExchExtCommands::DoCommand.

Is there any way around this?
 
K

Ken Slovak - [MVP - Outlook]

In an Explorer Ctrl+P will execute the File, Print CommandBarButton. You
should be able to set a button instance to that object and handle the
Click() event for it.
 
M

Mark Wilson

Hi Ken.

In the testing I did it seemed that the button click event was bypassed when
a keyboard shortcut was used. I'll retest.
 
K

Ken Slovak - [MVP - Outlook]

In that case the only way I know that would work would be to subclass
messages to the Outlook window looking for that keystroke combination.
 
M

Mark Wilson

Ken, I just retested that.

Clicking on the button on the toolbar activates my ButtonClick code. Typing
CTRL+P bypasses it.

Since this is a managed newsgroup, Microsoft is supposed to answer posts
within 2 days. Its been a week now with no response from a Microsoft
representative.

Hello??
 
C

Colbert Zhou [MSFT]

Hello Mark,

First sorry for my late response. This question is a bit difficulty. I saw
Ken jumped in and based on my research, I did not find any other approaches
to achieve that goal, so I did not jump in for no values to add.

I use Spy++ to look for Ctrl+P message in Outlook. But unfortunately, they
are also not available. So SubClass here is either not an option.

I am afraid the only way to achieve that objective may be setting a low
level keyboard hook on Outlook application.
1. To know about how to set a low level keyboard hook via C# and related
information, you can refer to this blog and its comments,
http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx

2. To know how to apply this to Outlook addin application, you can refer to
one of my old threads in VSTO forum,
http://social.msdn.microsoft.com/forums/en-US/vsto/thread/dfe87372-c0a5-46c7
-ac2f-76def7c4d079/

I did not mention this because based on my test, setting a hook on Outlook
application will definitely slow down the Outlook's performance. Thus, this
approach is not recommended. So if you decide to go this way, you'd better
test and evaluate whether it can meet the customer's performance demand.


Best regards,
Ji Zhou
Microsoft Online Community Support
 
M

Mark Wilson

Thanks for the reply Ji.

So to sumarize the situation, in Outlook 2007 you can still trap some
keyboard shortcuts with an ECE. In Outlook 2010 the removal of support for
ECEs will mean that there is no Microsoft supported way to intercept keyboard
shortcuts.

My code is a C++ native addin, not C#/VSTO.

So if I did use a low level hook, is there any way to get access to the OOM
for such things as ActiveInspector etc?

The KeyboardProc Function has 3 parameters passed in to it and none of them
appear to be anyting that a user can define. Is the only way to get back to
the current message to store a referece to the Application object in a
global variable?

This is getting really messy.
 

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