![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hey what's up...
I've come across the same basic problem but with an Excel 2003 add-in. I created a shared add-in as an "other project type" under extensibility as a shared add-in with excel as the app it should be used for. I struggled with it for a while when it wasn't working and discovered I needed an update to make it work. Microsoft Visual Studio 2005 shared add-in support update(KB908002). Once I installed the update everything was fine. If it helps here's a sample of the class code I used to make it work after I installed the update. This code adds a button to the standard toolbar of excel. You should be able to take the basic idea and extrapolate it for your own use. ----------------------------------------------------------------------------------------- Imports Microsoft.Office.Core Imports Extensibility Imports System.Runtime.InteropServices GuidAttribute("7B208F7B-3DEA-4BA1-BBEB-10D2D9070EDF"), ProgIdAttribute("MyAddin1.Connect") _ Public Class Connect Implements Extensibility.IDTExtensibility2 Dim WithEvents MyButton As CommandBarButton Dim applicationObject As Object Dim addInInstance As Object Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown 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 MyButton = applicationObject.CommandBars("Standard").Controls .Add(1) MyButton.Caption = "My Button" MyButton.Style = MsoButtonStyle.msoButtonCaption MyButton.Tag = "My Button" MyButton.OnAction = "!MyAddin1.Connect" End Sub Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection 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 End Sub Private Sub MyButton_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, _ ByRef CancelDefault As Boolean) Handles MyButton.Click msgbox("This works") End Sub End Class ----------------------------------------------------------------------------- This solution all applies to VS2005 and Office 2003 so I hope it helps. Take care, -- Phillipians 4v6-8 Jim Bourque "lostwings" wrote: I wanted to use com add-in to add one menu for the outlook 2003. The thing is that it seems that I cannot create the CommandBars Collection object successfully. Following is the code snippet. Imports Microsoft.Office 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 oApp = CType(application, Microsoft.Office.Interop.outlook.Application) Dim myCommandBars As Microsoft.Office.Core.CommandBars myCommandBars = oApp.ActiveExplorer.CommandBars end sub I omit some exception catch statement above. The compiler alwasy report error as "CommandBars is ambiguous in the namespace 'Microsoft.office.core' ". Why is that, and how can I fix this error? thanks in advance. -- John 3:16 |
Ads |
Thread Tools | Search this Thread |
Display Modes | |
|
|