467,861 Members | 1,487 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,861 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

<GuidAttribute("CF8D33FD-F4C4-4F9B-BC82-051BF38F2E25"),
ProgIdAttribute("MyAddin3.Connect")_

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
Extensibility.IDTExtensibility2.OnBeginShutdown

btn.Delete()

applicationObject.commandbars("Addin3").delete()

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 objBars As CommandBars

Dim objBar As CommandBar

On Error Resume Next

objBars = applicationObject.commandbars

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

objBars.Add(Name:="Addin3")

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")

objBar.Controls.Item("Button1").Delete()

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
Extensibility.IDTExtensibility2.OnDisconnection

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
  • viewed: 1816
Share:

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 jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.