chris.s
08-23-2011, 08:05 AM
Hi all,
I've written a macro in Outlook that is triggered when the "Send" button is pushed on an email, popping up a custom form that lists who the email was addressed to and giving users one last chance to make changes before sending. Works great.
Now, when in Excel (2007 for example), and Office Button->Send->Email is selected, even though it opens an Outlook mail window, it does not call the Outlook macro when Send is pressed and just sends the email right away.
The exception to this is when the new mail window is spawned by Excel, before I actually hit send, I open and close the VB Editor window from the mail item's ribbon bar. Then it runs my macro, but it crashes Outlook, Excel throws an error and both VB and the Outlook VB Editor is unable to open afterwards. Anybody have any idea why this is happening and how to get it to run properly from Excel?
The code that calls the custom form is the following, in ThisOutlookSession:
----------------
Private Sub Application_ItemSend _
(ByVal Item As Object, Cancel As Boolean)
Dim strMsg As String
Dim popUpBox As ConfirmBox
Set popUpBox = New ConfirmBox
If Item.MessageClass = "IPM.Note" Then
strMsg = "To recipients = " & Item.To & vbCrLf & vbCrLf & _
"Cc recipients = " & Item.CC & vbCrLf & vbCrLf & _
"Are you sure you want to send this message?"
popUpBox.TextBox1.Text = strMsg
popUpBox.Show
If popUpBox.Tag = 0 Then
Cancel = True
End If
End If
Unload popUpBox
End Sub
---------------------
Thanks in advance,
-Chris
I've written a macro in Outlook that is triggered when the "Send" button is pushed on an email, popping up a custom form that lists who the email was addressed to and giving users one last chance to make changes before sending. Works great.
Now, when in Excel (2007 for example), and Office Button->Send->Email is selected, even though it opens an Outlook mail window, it does not call the Outlook macro when Send is pressed and just sends the email right away.
The exception to this is when the new mail window is spawned by Excel, before I actually hit send, I open and close the VB Editor window from the mail item's ribbon bar. Then it runs my macro, but it crashes Outlook, Excel throws an error and both VB and the Outlook VB Editor is unable to open afterwards. Anybody have any idea why this is happening and how to get it to run properly from Excel?
The code that calls the custom form is the following, in ThisOutlookSession:
----------------
Private Sub Application_ItemSend _
(ByVal Item As Object, Cancel As Boolean)
Dim strMsg As String
Dim popUpBox As ConfirmBox
Set popUpBox = New ConfirmBox
If Item.MessageClass = "IPM.Note" Then
strMsg = "To recipients = " & Item.To & vbCrLf & vbCrLf & _
"Cc recipients = " & Item.CC & vbCrLf & vbCrLf & _
"Are you sure you want to send this message?"
popUpBox.TextBox1.Text = strMsg
popUpBox.Show
If popUpBox.Tag = 0 Then
Cancel = True
End If
End If
Unload popUpBox
End Sub
---------------------
Thanks in advance,
-Chris