Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.Net Com Add-In for MS Outlook, click event procedure for Com Add-In

Status
Not open for further replies.

fmeis

MIS
Joined
Nov 21, 2003
Messages
1
Location
US
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(&quot;DD77002A-2978-45C1-9A2C-F4E136206AC8&quot;), ProgIdAttribute(&quot;myAddin.Connect&quot;)> _
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 &quot;Standard&quot; command bar.

oCommandBars = applicationObject.CommandBars

If oCommandBars Is Nothing Then
oCommandBars = applicationObject.ActiveExplorer.CommandBars
End If

oStandardBar = oCommandBars.Item(&quot;Standard&quot;)

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

If myButton Is Nothing Then

myButton = oStandardBar.Controls.Add(1)
With myButton
.Caption = &quot;myButtonCaption&quot;
.Style = MsoButtonStyle.msoButtonIconAndCaption
.Tag = &quot;myButtonTag&quot;
.FaceId = 271
.OnAction = &quot;!<myAddin.Connect>&quot;
.DescriptionText = &quot;Click me and Run my vb.net program&quot;
.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(&quot;c:\myVBprogram.exe&quot;, IO.FileMode.Open) --- doesn't work


End Sub


End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top