Option Explicit
'Added references:
'Microsoft Office xx.0 Object Library
'Microsoft Outlook xx.0 Object Library
'Microsoft AddIn Designer
'Microsoft Visual Basic 6.0 Extensibility
Implements IDTExtensibility2
Public moApp As Outlook.Application
Public moAppInst As Object
Public WithEvents moCBMeow As Office.CommandBarButton
Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
'<PLACEHOLDER - I AM NOT USING IT FOR DEMO, ONLY FOR COMPATIBILITY STANDARDS>
'The OnAddInsUpdate method is called when a change occurs to the list of add-ins in the COM Add-Ins dialog box,
'such as when an add-in is loaded or unloaded. The custom parameter is an array that can be used to provide
'additional data to the OnAddInsUpdate method if desired.
End Sub
Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
'The OnBeginShutdown method is called while the environment is being shut down. The custom parameter is an array
'that can be used to provide additional data to the OnBeginShutdown method if desired.
If TypeName(moCBMeow) <> "Nothing" Then
moCBMeow.Delete
End If
Set moCBMeow = Nothing
End Sub
Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
'<INITIAL EVENT THAT FIRES WHEN TEH ADDIN IS LOADED>
'<SET THE PUBLIC APPLICATION OBJECT TO THE PASSED IN INSTANCE FOR SECURITY AND TRUST>
'The OnConnection method is called when the add-in is loaded into the environment. The addInInst parameter is an
'object that represents the instance of the managed COM add-in. The custom parameter is an array that can be used
'to use to provide additional data to the OnConnection method if desired. The application parameter represents the
'host application. The connectMode parameter is an ext_cm constant that indicates how the managed COM add-in was loaded.
Set moApp = Application
Set moAppInst = AddInInst
'<IF YOU ARE NOT IN STARTUP THEN MANUALLY CALL ONSTARTUPCOMPLETE>
If (ConnectMode <> AddInDesignerObjects.ext_ConnectMode.ext_cm_Startup) Then Call IDTExtensibility2_OnStartupComplete(custom)
End Sub
Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, _
custom() As Variant)
'The OnDisconnection method is called when the managed COM add-in is unloaded, such as when the user closes the
'host application. The custom parameter is an array that can be used to provide additional data to the OnDisconnection
'method if desired. The RemoveMode parameter is an ext_dm constant that indicates how the managed COM add-in was unloaded.
If TypeName(moCBMeow) <> "Nothing" Then
moCBMeow.Delete
End If
Set moCBMeow = Nothing
End Sub
Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
'<SET OUT TOLBAR BUTTON IN THIS EVENT AS ITS THE LAST TO FIRE SO OUTLOOK WILL BE COMPLETELY LOADED AND STARTED>
'The OnAction property is optional but recommended. It should be set to the ProgID of the add-in, so that if
'the add-in is not loaded when a user clicks the button, MSO loads the add-in automatically and then raises
'the Click event for the add-in to handle.
Set moCBMeow = moApp.ActiveExplorer.CommandBars.Item("Standard").FindControl(, , "890", False, True)
If TypeName(moCBMeow) = "Nothing" Then
Set moCBMeow = moApp.ActiveExplorer.CommandBars.Item("Standard").Controls.Add(msoControlButton, , "890", , True)
End If
With moCBMeow
.BeginGroup = True
.Caption = "Meow"
.DescriptionText = "Meow meow meow"
.Enabled = True
.OnAction = "!<RobDog888.Connect>"
Clipboard.Clear
Clipboard.SetData LoadPicture("C:\Cat.bmp")
.PasteFace
.Style = msoButtonIconAndCaption
.Tag = "890"
.ToolTipText = "Meow meow meow"
.Visible = True
End With
End Sub
Private Sub moCBMeow_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
'<OUR TOOLBAR BUTTON CLICK EVENT PROCEDURE>
MsgBox "Meow meow meow!", vbOKOnly + vbInformation, "RobDog888's VB 6 Add-In Outlook FAQ"
End Sub