I need a little help with this Com Add-In for MS Outlook. All I want the add-in to do is add a button to the toolbar, and when that button is clicked to run a vb.net program (an executable file). The following code displays a button on the toolbar, assigns a name and icon, but I cannot figure out how to make it run the executable file. In the click event procedure the code in comments access the file, but does doesn't display it. It seems to me that you cannot use the system.io commands in Outlook. Don't know what else to try. All suggestions welcome.
Thank You
Fred
might help to cut and paste into vb.net
--------------------------------------------------------
Imports Microsoft.Office.Core
imports Extensibility
imports System.Runtime.InteropServices
#Region " Read me for Add-in installation and setup information. "
' When run, the Add-in wizard prepared the registry for the Add-in.
' At a later time, if the Add-in becomes unavailable for reasons such as:
' 1) You moved this project to a computer other than which is was originally created on.
' 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
' 3) Registry corruption.
' you will need to re-register the Add-in by building the myAddinSetup project
' by right clicking the project in the Solution Explorer, then choosing install.
#End Region
<GuidAttribute("DD77002A-2978-45C1-9A2C-F4E136206AC8"
, ProgIdAttribute("myAddin.Connect"
> _
Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim applicationObject as Object
dim addInInstance as object
Dim WithEvents myButton As CommandBarButton
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
On Error Resume Next
myButton.Delete()
myButton = Nothing
End Sub
Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar
On Error Resume Next
' Set up a custom button on the "Standard" command bar.
oCommandBars = applicationObject.CommandBars
If oCommandBars Is Nothing Then
oCommandBars = applicationObject.ActiveExplorer.CommandBars
End If
oStandardBar = oCommandBars.Item("Standard"
' In case the button was not deleted, use the exiting one.
myButton = oStandardBar.Controls.Item("myButtonName"
If myButton Is Nothing Then
myButton = oStandardBar.Controls.Add(1)
With myButton
.Caption = "myButtonCaption"
.Style = MsoButtonStyle.msoButtonIconAndCaption
.Tag = "myButtonTag"
.FaceId = 271
.OnAction = "!<myAddin.Connect>"
.DescriptionText = "Click me and Run my vb.net program"
.Visible = True
End With
End If
oStandardBar = Nothing
oCommandBars = Nothing
End Sub
Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
On Error Resume Next
If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdown Then
Call OnBeginShutdown(custom)
End If
applicationObject = Nothing
End Sub
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.OnConnection
applicationObject = application
addInInstance = addInInst
On Error Resume Next
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then
Call OnStartupComplete(custom)
End If
End Sub
' ---- Below is the problem! ------ I need a line of code that will open my executable file when you click on myButton in the outlook toolbar.
Private Sub myButton_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles myButton.Click
' System.IO.File.Open("c:\myVBprogram.exe", IO.FileMode.Open) --- doesn't work
End Sub
End Class
Thank You
Fred
might help to cut and paste into vb.net
--------------------------------------------------------
Imports Microsoft.Office.Core
imports Extensibility
imports System.Runtime.InteropServices
#Region " Read me for Add-in installation and setup information. "
' When run, the Add-in wizard prepared the registry for the Add-in.
' At a later time, if the Add-in becomes unavailable for reasons such as:
' 1) You moved this project to a computer other than which is was originally created on.
' 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
' 3) Registry corruption.
' you will need to re-register the Add-in by building the myAddinSetup project
' by right clicking the project in the Solution Explorer, then choosing install.
#End Region
<GuidAttribute("DD77002A-2978-45C1-9A2C-F4E136206AC8"


Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim applicationObject as Object
dim addInInstance as object
Dim WithEvents myButton As CommandBarButton
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
On Error Resume Next
myButton.Delete()
myButton = Nothing
End Sub
Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar
On Error Resume Next
' Set up a custom button on the "Standard" command bar.
oCommandBars = applicationObject.CommandBars
If oCommandBars Is Nothing Then
oCommandBars = applicationObject.ActiveExplorer.CommandBars
End If
oStandardBar = oCommandBars.Item("Standard"

' In case the button was not deleted, use the exiting one.
myButton = oStandardBar.Controls.Item("myButtonName"

If myButton Is Nothing Then
myButton = oStandardBar.Controls.Add(1)
With myButton
.Caption = "myButtonCaption"
.Style = MsoButtonStyle.msoButtonIconAndCaption
.Tag = "myButtonTag"
.FaceId = 271
.OnAction = "!<myAddin.Connect>"
.DescriptionText = "Click me and Run my vb.net program"
.Visible = True
End With
End If
oStandardBar = Nothing
oCommandBars = Nothing
End Sub
Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
On Error Resume Next
If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdown Then
Call OnBeginShutdown(custom)
End If
applicationObject = Nothing
End Sub
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.OnConnection
applicationObject = application
addInInstance = addInInst
On Error Resume Next
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then
Call OnStartupComplete(custom)
End If
End Sub
' ---- Below is the problem! ------ I need a line of code that will open my executable file when you click on myButton in the outlook toolbar.
Private Sub myButton_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles myButton.Click
' System.IO.File.Open("c:\myVBprogram.exe", IO.FileMode.Open) --- doesn't work
End Sub
End Class