VBA in Outlook - Automating a Macro

  Heefie 12:16 30 May 2008
Locked

Hopefully comebody can help ... I have written a Macro that is executed by the click of a button on the Standard Toolbar. This Macro works perfectly & does exactly what I want.

I'd now like to automate this Macro so that it runs every time a Send/Receive completes. Having searched the Internet, it seems that the NEWMAILEX command is my answer, but it doesn't work for me at the moment and most places where the usage of it is discussed, seem to be poulated by pretentious nerds who are unable to describe anything in plain English, it seems they are only allowed to drop subtle hints !!!

I have amended my first line from

Sub Turns() to Sub Turns_NewMailEx()

I haven't used the "ByVal EntryIDCollection As String" parameters, that are included in most sites, as I am unconcerned about the E:Mails themselves or an identifiers on them, I just want my already working Macro to execute. As things stand, nothing has changed, the Macro still doesn't run automatically after a Send/REceive ...

My macro is a Module, is this OK or should it be in the "ThisOutlookSession" code ?

A couple of sites mention initialising my Macro & one site has some code ...

Sub Intialize_Handler()
Set Turns = Application * Amended to say Turns
End Sub

... but I don't know if I NEED this & if I do, where it should go ...

So, in summary, can anybody explain what I am doing wrong and/or what I need to do to make this Macro run automatically ?!?

Thanks ...

  Heefie 14:12 30 May 2008

... in case anybody wants to know ... adding the following code into the Application / folder "ThisOutlookSession" executes the Turns Macro whenever new E:Mail is received :

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Call Turns
End Sub

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Alienware 17 R4 2017 review

These brilliant Lego posters show just what children's imaginations are capable of

Mac power user tips and hidden tricks

Comment réinitialiser votre PC, ordinateur portable ou tablette Windows ?