470,648 Members | 1,521 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,648 developers. It's quick & easy.

Shared Addin not working in Excel and Word but working in Powerpoint

I am trying to create a shared addin using visual studio 2005 with the
following code. It is working only in Power Point Appliction and not loading
in Excel and Word I used the Visual Studio Wizard to create shared addin and
seleted the Programs Power Point, Excel and Word. I am using the Office XP:
imports Extensibility

imports System.Runtime.InteropServices

Imports Microsoft.Office.Core

Imports Microsoft.Office.Core.MsoButtonStyle

Imports Microsoft.Office.Core.MsoControlType

Imports Microsoft.Office.Core.MsoBarPosition


Public Class Connect
Implements Extensibility.IDTExtensibility2

Dim applicationObject as Object

Dim addInInstance as object

Dim WithEvents btn As CommandBarButton

Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements



End Sub
Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements

End Sub
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements

Dim objBars As CommandBars

Dim objBar As CommandBar

On Error Resume Next

objBars = applicationObject.commandbars

If IsNothing(objBars.FindControl(Tag:="Addin3")) Then


With objBars.Item("Addin3")

..Visible = True

..Protection = MsoBarProtection.msoBarNoCustomize

..Position = msoBarTop

End With

End If

If objBars.Item("Addin3").Visible = False Then

objBars.Item("Addin3").Visible = True

End If

objBar = objBars.Item("Addin3")


btn = objBar.Controls.Add(1)

With btn

..Caption = "Button1"

..Tag = "Button1"

..Style = msoButtonCaption

..OnAction = "!<MyAddin3.Connect>"

..Visible = True

End With

MsgBox("Addin3 is loaded")

End Sub
Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements

If RemoveMode <ext_DisconnectMode.ext_dm_HostShutdown Then

Call OnBeginShutdown(custom)

applicationObject = Nothing

End If

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

If (connectMode <ext_ConnectMode.ext_cm_Startup) Then

Call OnStartupComplete(custom)

End If
End Sub

Private Sub btn_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton,
ByRef CancelDefault As Boolean) Handles btn.Click

MsgBox("Button was pressed")

End Sub

End Class
Dec 2 '07 #1
0 1887

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Alexander Czernay | last post: by
reply views Thread by Debarati Chatterjee - IT professional | last post: by
reply views Thread by liam_jones | last post: by
1 post views Thread by shantanu | last post: by
reply views Thread by warner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.