i have created add-in for Outlook 2007 . but when i run outlook the commandbar button which should be appear on standard bar , does not appear.
i think there is a problem in register of Add-in.
the code are as follows :
imports Extensibility
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop
#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 $SAFEOBJNAME$Setup project,
' right click the project in the Solution Explorer, then choose install.
#End Region
<GuidAttribute("F5F9500E-08F4-4391-B2F7-29FDE0BB4C23"), ProgIdAttribute("ISOLAddin.Connect")> _
Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim applicationObject As Object
Dim addInInstance As Object
Dim WithEvents MyButton As Microsoft.Office.Core.CommandBarButton
Dim OApp As Outlook.Application
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
MsgBox("Our custom Add-in is unloading.")
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 ComBar As CommandBars
Dim StdBar As CommandBar
Dim OAppExpl As Outlook.Explorer
OAppExpl = CType(OApp.ActiveExplorer, Outlook.Explorer)
ComBar = OAppExpl.CommandBars
If ComBar Is Nothing Then
ComBar = OApp.ActiveExplorer.CommandBars
End If
ComBar = applicationObject.CommandBars()
StdBar = ComBar.Item("Standard")
If StdBar Is Nothing Then
StdBar = ComBar.Item("Database")
End If
MyButton = CType(StdBar.FindControl(Tag:="My Custom Button"), CommandBarButton)
If MyButton Is Nothing Then
MyButton = CType(StdBar.Controls.Add(Type:=MsoControlType.msoControlButton, Temporary:=False), CommandBarButton)
With MyButton
.Caption = "My Custom Button"
.Style = MsoButtonStyle.msoButtonCaption
.Tag = "My Custom Button"
.OnAction = "!<ISOLAddin.connect>"
.Visible = True
End With
End If
MsgBox("Started in " & OApp.Name & ".")
ComBar = Nothing
StdBar = Nothing
End Sub
Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
If RemoveMode <> ext_DisconnectMode.ext_dm_HostShutdown Then
Call OnBeginShutdown(custom)
End If
OApp = 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
MsgBox("On Connection In MyAddin")
applicationObject = application
addInInstance = addInInst
If connectMode <> ext_ConnectMode.ext_cm_Startup Then
Call OnStartupComplete(custom)
End If
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
End Class
please tell me , what is the problem in this ?
Thanks !