View Single Post
  #7  
Old April 23rd 08, 03:42 PM posted to microsoft.public.outlook.program_vba
Mike YO_BEE B
external usenet poster
 
Posts: 7
Default Can I capture the event ItemSend from a macro?

would it be something like this under the Class Modules ?

Public Sub Startup()
Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & "?"
If MsgBox(prompt, 4 + 16, "This is a Warning!") = vbNo Then
Cancel = True
End If

End Sub


"Ken Slovak - [MVP - Outlook]" wrote:

Put that code in the ThisOutlookSession class module. You don't need to
declare an Application object WithEvents in that class BTW. Then in the
Application_Startup event handler call your initialization.

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


"Mike "YO_BEE" B" wrote in message
...
Here is my code. I am a newbie at coding, but I found this and it works,
but
I am not sure how to have this code start up automaticlly upon the start
up
of OUTLOOK

Public WithEvents myOlApp As Outlook.Application

Public Sub Initialize_handler()
Set myOlApp = CreateObject("Outlook.Application")
End Sub

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & "?"
If MsgBox(prompt, 4 + 16, "This is a Warning!") = vbNo Then
Cancel = True
End If

End Sub


"Totem" wrote:

Hi,

I'm trying to capture the ItemSend event from a macro (not an add-in),
but
for whatever reason it's not hitting it. Even after restarting Outlook
(2007), it does not kick in. Do I have to do something special?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
MsgBox("hi")
End Sub

or do I have to write an add-in?

Thanks



Ads