Hayat Hayat - 3 years ago 286
Vb.net Question

VBA alternative of Application.Quit Event for VB.Net for Outlook VSTO

Is there any VBA alternative of

Event for Outlook VSTO AddIn in VB.Net ? Visual Studio have a default statement for Shutdown event in Outlook VSTO template which seem to not working or I'm not sure how to make this work

Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
End Sub

I found this below code in MSDN which is working only in VBA, But I need this event handler for Outlook Addin so that I can trigger some event before outlook close.

Private Sub Application_Quit()
MsgBox "Goodbye, " &; Application.GetNamespace("MAPI").CurrentUser
End Sub

Answer Source

Try this:

Public Class ThisAddIn

    Private Sub ThisAddIn_Startup() Handles Me.Startup
        AddHandler Application.Quit, AddressOf Application_Quit
    End Sub

    Private Sub Application_Quit()
         ' Your code
    End Sub

End Class
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download