VBA to intercept creation of new messages?

  • Thread starter Thread starter xtine
  • Start date Start date
X

xtine

Hi

In Word if I create a macro called FileNew which pops up a message box
then it will override the default file new code.

What is the equivalent of FileNew in Outlook 2007 so that I can
override the default functionality? and which template/where should I
store
it in so that it works every time.

I have tried making a normalemail.dot but although it keeps my styles
it loses any keystrokes I have assigned and the multilevel numbering.

I tried saving the styles as a styleset and that works, but I have to
switch to the styleset manually each time.

I then created an oft file which works, but I can't work out how to
get it to be the default - so I thought maybe I could 'catch' the
FileNew process and call it that way?

Any other ideas on how to set up a default message that has multi-
level numbered styles with keystrokes attached?

Christine
 
You will need to have your OFT file published to be able to use it. You can
intercept the Inspectors.NewInspector event and set the MessageClass of the
new item in Inspector.CurrentItem to your custom MessageClass.

For instructions on making a custom form the default form for an item type
look at the Forms pages at www.outlookcode.com.
 
And note that it's generally a bad idea to make a custom form the default for all messages, unless you're working in an Exchange environment and have tested to confirm that the server is converting outgoing messages so that they don't carry TNEF content.

Christine, you didn't say what you're actually trying to accomplish with your custom form. Chances are that it can be implemented better with an add-in./

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Ken Slovak - said:
You will need to have your OFT file published to be able to use it. You can
intercept the Inspectors.NewInspector event and set the MessageClass of the
new item in Inspector.CurrentItem to your custom MessageClass.

For instructions on making a custom form the default form for an item type
look at the Forms pages at www.outlookcode.com.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


xtine said:
Hi

In Word if I create a macro called FileNew which pops up a message box
then it will override the default file new code.

What is the equivalent of FileNew in Outlook 2007 so that I can
override the default functionality? and which template/where should I
store
it in so that it works every time.

I have tried making a normalemail.dot but although it keeps my styles
it loses any keystrokes I have assigned and the multilevel numbering.

I tried saving the styles as a styleset and that works, but I have to
switch to the styleset manually each time.

I then created an oft file which works, but I can't work out how to
get it to be the default - so I thought maybe I could 'catch' the
FileNew process and call it that way?

Any other ideas on how to set up a default message that has multi-
level numbered styles with keystrokes attached?

Christine
 
Christine, you didn't say what you're actually trying to accomplish with your custom form. Chances are that it can be implemented better with an add-in./

Hi

All we are trying to do is to present the users with a default blank
'template' that has a restricted set of styles in it (which happens to
be a multi-level numbered list). This is so that the users can send
an email in the 'house style', using the same keystrokes that they use
in Word 2007 to create documents. There are no fields or anything on
the template - its blank.

As we have not yet rolled out Word 2007 we can change which keystrokes
are used, but to date I haven't managed to get the keystrokes to
'stick' other than using my .oft

Basically I need 5 levels of numbered heading and 5 indented paragraph
styles, all based on a style we have called ParaBase which is Arial
12pt, 12pt after... so not anything 'non standard' there.

We don't want the users to be able to change styleset or to be able to
use all the inbuilt styles - so these need to be 'hidden'.

I have all of this working in my .oft - the problem is that to get to
it the users would need to click several times and they won't do this
- they will just use the default, so they will end up sending out
documents that don't conform to the house numbering styles etc.

Christine
 
That sounds like it might be a job for Quick Styles in the normalemail.dotm template. Seehttp://turtleflock-ol2007.spaces.live.com/blog/cns!C1013F1F9A99E3D8!1...

Thanks Sue, unfortunately thats what I tried first - and it does show
the user the styles in the style gallery - but they lose their
keystroke and numbering properties - if you open the .dotm in Word its
all hunky dory, but create a new message and you only see the font and
paragraph formatting not the numbers. If you do 'Save as a Style
Set' while you are in Word you can pick the styleset from within
Outlook - but again you have to go looking for it.

I wonder if there is a way of choosing the default StyleSet using a
registry setting?


Christine
 
I suspect that might be possible only by using an add-in to completely rewrite the formatting portion of the ribbon.

This is achievable using the Manage Styles options in Word to restrict
and hid the inbuilt styles - haven't tested yet to see if saving this
in normalemail.dotm carries the restrictions forward to Outlook. I
know it does if you create a new mail based on the .oft.


Christine
 
Back
Top