Cannot return the public property of a COM add-in in Office 2003 (825937)



The information in this article applies to:

  • Microsoft Office 2003, All Editions

SYMPTOMS

When you try to return a public property of a COM Add-in in a Microsoft Office 2003 program, the property is not returned.

For example, this problem is illustrated in the following Visual Basic for Applications (VBA) macro code:
Sub MyProperty()

   Dim X as Object
   'Reference the COM object for the COM Addin specified by <progID>
   Set X = Application.COMAddins.Item(<progID>).Object

   'State is a public property of the COM Addin specified by <progID>
   Debug.Print X.State

End Sub

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To return the public properties of a COM add-in, use one of the following code examples:
Sub MyProperty()

   Dim X as Object

   Set X = CreateObject(<progID>)

   'State is a public property of the COM Addin specified by <progID>
   Debug.Print X.State

End Sub
-or-
Sub MyProperty()

   Dim X as Object
   'Create a new object using the <progID> of the COM Addin object at 
   'Index 1 in the collection.
   Set X = CreateObject(Application.COMAddins(1).ProgId) 

   'State is a public property of the COM Addin specified in the previous line.
   Debug.Print X.State

End Sub

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Modification Type:MinorLast Reviewed:1/10/2006
Keywords:kbAddIn KbVBA kbmacroexample kbcode KB825937 kbAudDeveloper kbAudITPRO