Option Explicit
'Class members
Private WithEvents m_cbbMenu As _
Office.CommandBarButton
Private m_frmTask As frmTask
Private Sub m_cbbMenu_Click(ByVal Ctrl _
As Office.CommandBarButton, _
CancelDefault As Boolean)
On Error Resume Next
If Not g_COutlook.Logon() Then
MsgBox "Logon to Outlook Failed"
Else
m_frmTask.Show vbModal
End If
End Sub
Private Sub AddinInstance_OnConnection _
ByVal Application As Object, ByVal _
ConnectMode As _
AddInDesignerObjects.ext_ConnectMode _
, ByVal AddInInst As Object, custom() _
As Variant)
On Error Resume Next
'store startup references, connect
' Command Bar, instance Outlook
Set g_oHostApp = Application
Set g_oAddIn = AddInInst
Set m_cbbMenu = ConnectCommandBar()
Set g_COutlook = New COutlook
End Sub
Private Sub AddinInstance_OnDisconnection _
(ByVal RemoveMode As _
AddInDesignerObjects.ext_DisconnectMode
, custom() As Variant)
On Error Resume Next
g_COutlook.Logoff
Set g_COutlook = Nothing
DisconnectCommandBar
'remove references to shut down
Set m_cbbMenu = Nothing
Set g_oAddIn = Nothing
Set g_oHostApp = Nothing
End Sub
Private Sub AddinInstance_Initialize()
'create hidden form instance
Set m_frmTask = New frmTask
End Sub
Private Sub AddinInstance_Terminate()
Set m_frmTask = Nothing
End Sub
|