C
Chris W
Hi
I'm writing my first Outlook add-in using VB.NET (first time in VB as well) and I've run into a couple of issues with the just the most basic of functionality (primarily code from MSDN)
First, the OnBeginShutdown and OnDisconnect events do not appear to be firing, which is leaving the Outlook process running. I've implemented the apparent workaround of creating a Close handler for the Explorer.Close event, but that also does not appear to be getting hit
Second, and my main concern, is that the BeforeFolderSwitch Explorer event does not appear to be firing either? Perhaps I am doing something wrong. The addin *is* being loaded, so it's not something simple like that :
Thanks for any help you can provide
XP Pr
Outlook 2000 SP
Visual Studio .NET 200
Public Class Connec
Implements Extensibility.IDTExtensibility
Dim WithEvents m_btnConfig As CommandBarButto
Dim WithEvents m_olOutlook As Outlook.Applicatio
Dim WithEvents m_olExplorer As Outlook.ExplorerClas
Dim applicationObject as Objec
dim addInInstance as objec
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdow
On Error Resume Nex
m_btnConfig.Delete(
m_btnConfig = Nothin
m_olExplorer = Nothin
m_olOutlook = Nothin
End Su
Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdat
End Su
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplet
Dim oCommandBars As CommandBar
Dim oStandardBar As CommandBa
On Error Resume Nex
' Set up a custom button on the "Standard" command bar
oCommandBars = applicationObject.CommandBar
If oCommandBars Is Nothing The
' Outlook has the CommandBars collection on the Explorer object
oCommandBars = applicationObject.ActiveExplorer.CommandBar
End I
oStandardBar = oCommandBars.Item("Standard"
m_btnConfig = oStandardBar.Controls.Item("Configure"
If m_btnConfig Is Nothing The
m_btnConfig = oStandardBar.Controls.Add(1
With m_btnConfi
.Caption = "Configure
.Style = MsoButtonStyle.msoButtonCaptio
' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when more tha
' one application window is visible. The property is require
' by some Office applications and should be provided
.Tag = "Configure
' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, so that i
' the add-in is not loaded when a user clicks the button
' MSO loads the add-in automatically and then raise
' the Click event for the add-in to handle.
.OnAction = "!<MyCOMAddin.Connect>
.Visible = Tru
End Wit
End I
' Display a simple message to show which application you started in
'MsgBox("Started in " & applicationObject.Name & "."
oStandardBar = Nothin
oCommandBars = Nothin
End Su
Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnectio
On Error Resume Nex
If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdown Then
Call OnBeginShutdown(custom
addInInstance = Nothin
applicationObject = Nothin
End Su
Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnectio
'MsgBox("On Connection In MyAddin")
applicationObject = application
addInInstance = addInInst
' If you aren't in startup, manually call OnStartupComplete.
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _
Call OnStartupComplete(custom)
End Sub
Private Sub MyButton_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles MyButton.Click
MsgBox("Our CommandBar button was pressed!")
End Sub
Private Sub m_olExplorer_BeforeFolderSwitch(ByVal NewFolder As Object, ByRef Cancel As Boolean) _
Handles m_olExplorer.BeforeFolderSwitch
MsgBox("BeforeFolderSwitch")
End Sub
Private Sub m_olExplorer_FolderSwitch() Handles m_olExplorer.FolderSwitch
MsgBox("FolderSwitch")
End Sub
Sub m_olExplorer_Close()
m_olExplorer = Nothing
End Sub
End Class
I'm writing my first Outlook add-in using VB.NET (first time in VB as well) and I've run into a couple of issues with the just the most basic of functionality (primarily code from MSDN)
First, the OnBeginShutdown and OnDisconnect events do not appear to be firing, which is leaving the Outlook process running. I've implemented the apparent workaround of creating a Close handler for the Explorer.Close event, but that also does not appear to be getting hit
Second, and my main concern, is that the BeforeFolderSwitch Explorer event does not appear to be firing either? Perhaps I am doing something wrong. The addin *is* being loaded, so it's not something simple like that :
Thanks for any help you can provide
XP Pr
Outlook 2000 SP
Visual Studio .NET 200
Public Class Connec
Implements Extensibility.IDTExtensibility
Dim WithEvents m_btnConfig As CommandBarButto
Dim WithEvents m_olOutlook As Outlook.Applicatio
Dim WithEvents m_olExplorer As Outlook.ExplorerClas
Dim applicationObject as Objec
dim addInInstance as objec
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdow
On Error Resume Nex
m_btnConfig.Delete(
m_btnConfig = Nothin
m_olExplorer = Nothin
m_olOutlook = Nothin
End Su
Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdat
End Su
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplet
Dim oCommandBars As CommandBar
Dim oStandardBar As CommandBa
On Error Resume Nex
' Set up a custom button on the "Standard" command bar
oCommandBars = applicationObject.CommandBar
If oCommandBars Is Nothing The
' Outlook has the CommandBars collection on the Explorer object
oCommandBars = applicationObject.ActiveExplorer.CommandBar
End I
oStandardBar = oCommandBars.Item("Standard"
m_btnConfig = oStandardBar.Controls.Item("Configure"
If m_btnConfig Is Nothing The
m_btnConfig = oStandardBar.Controls.Add(1
With m_btnConfi
.Caption = "Configure
.Style = MsoButtonStyle.msoButtonCaptio
' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when more tha
' one application window is visible. The property is require
' by some Office applications and should be provided
.Tag = "Configure
' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, so that i
' the add-in is not loaded when a user clicks the button
' MSO loads the add-in automatically and then raise
' the Click event for the add-in to handle.
.OnAction = "!<MyCOMAddin.Connect>
.Visible = Tru
End Wit
End I
' Display a simple message to show which application you started in
'MsgBox("Started in " & applicationObject.Name & "."
oStandardBar = Nothin
oCommandBars = Nothin
End Su
Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnectio
On Error Resume Nex
If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdown Then
Call OnBeginShutdown(custom
addInInstance = Nothin
applicationObject = Nothin
End Su
Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnectio
'MsgBox("On Connection In MyAddin")
applicationObject = application
addInInstance = addInInst
' If you aren't in startup, manually call OnStartupComplete.
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _
Call OnStartupComplete(custom)
End Sub
Private Sub MyButton_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles MyButton.Click
MsgBox("Our CommandBar button was pressed!")
End Sub
Private Sub m_olExplorer_BeforeFolderSwitch(ByVal NewFolder As Object, ByRef Cancel As Boolean) _
Handles m_olExplorer.BeforeFolderSwitch
MsgBox("BeforeFolderSwitch")
End Sub
Private Sub m_olExplorer_FolderSwitch() Handles m_olExplorer.FolderSwitch
MsgBox("FolderSwitch")
End Sub
Sub m_olExplorer_Close()
m_olExplorer = Nothing
End Sub
End Class