By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

VBA does not see public class variables in COM addin

P: n/a
Is it possible to see public class variables of a COM addin in Excel 97 VBA?

I have successfully created the (Visual Basic 2003 .NET) COM
and referenced it in an Excel 97 VBA project. The VBA object browser sees -
and the project otherwise successfully interacts with - all the COM addin
methods and properties, but none of the public variables - target, init and
size in the code below - can be accessed. When I reference the exact same COM
from another dotnet project, the COM class public variables are all available.

What is going on here?

I notice that I have to choose the COM addin's .tlb file, not the .dll file in
the VBA reference dialog box. Is that expected?

Can Excel 97 VBA just not access COM class variables - or "fields" as the
dotnet documentation calls them? If so, that is going to be a serious
limitation for me.

The vb.net code of the COM addin I am using is like this:

<ComClass(fpm_goalseek_class.ClassId, _
fpm_goalseek_class.EventsId, _
fpm_goalseek_class.InterfaceId)> _
Public Class fpm_goalseek_class

Public Const ClassId As String = "6C1967B7-4EC8-4b70-BA94-C131EE892452"
Public Const InterfaceId As String = "4CDC9471-D4E2-4824-BD4D-938EF299D58C"
Public Const EventsId As String = "4D18D7F1-BC51-49f0-824B-69F607EBD3B2"

Public target as double
Public init as double
Public size as double

' . . . Body of class code here . . .

End Class
|\|.
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,

I would expose a public property instead of a public variable.

Ken
--------------
"Nick Dreyer" <gu****@oz.net> wrote in message
news:42**************@news.oz.net...
Is it possible to see public class variables of a COM addin in Excel 97 VBA?

I have successfully created the (Visual Basic 2003 .NET) COM
and referenced it in an Excel 97 VBA project. The VBA object browser sees -
and the project otherwise successfully interacts with - all the COM addin
methods and properties, but none of the public variables - target, init and
size in the code below - can be accessed. When I reference the exact same
COM
from another dotnet project, the COM class public variables are all
available.

What is going on here?

I notice that I have to choose the COM addin's .tlb file, not the .dll file
in
the VBA reference dialog box. Is that expected?

Can Excel 97 VBA just not access COM class variables - or "fields" as the
dotnet documentation calls them? If so, that is going to be a serious
limitation for me.

The vb.net code of the COM addin I am using is like this:

<ComClass(fpm_goalseek_class.ClassId, _
fpm_goalseek_class.EventsId, _
fpm_goalseek_class.InterfaceId)> _
Public Class fpm_goalseek_class

Public Const ClassId As String = "6C1967B7-4EC8-4b70-BA94-C131EE892452"
Public Const InterfaceId As String =
"4CDC9471-D4E2-4824-BD4D-938EF299D58C"
Public Const EventsId As String = "4D18D7F1-BC51-49f0-824B-69F607EBD3B2"

Public target as double
Public init as double
Public size as double

' . . . Body of class code here . . .

End Class
|\|.
Nov 21 '05 #2

P: n/a
Thanks for the thought, however . . .

I am quite aware that properties are substitutes for exposed class variables.

I just don't know what the point of going through all the trouble of setting
up property let/set code for every single variable that needs to be accessed
outside the VB.NET class.

Are you telling me that there is no way of exposing public class variables in
VB.NET COM builds? If so what's the point of the "public" qualifier for class
variables in VB.NET?

VB.NET makes public variables visible to other VB.NET projects, why won't COM?

I appreciate any more insights into this matter, if only in the form (or
reference to source) of a good explanation as to why exposing public variables
is not worthy of support in COM.

Thanks in advance, |\|.

On Sat, 9 Jul 2005 06:30:20 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net>
wroth:
Hi,

I would expose a public property instead of a public variable.

Ken
--------------
"Nick Dreyer" <gu****@oz.net> wrote in message
news:42**************@news.oz.net...
Is it possible to see public class variables of a COM addin in Excel 97 VBA?

I have successfully created the (Visual Basic 2003 .NET) COM
and referenced it in an Excel 97 VBA project. The VBA object browser sees -
and the project otherwise successfully interacts with - all the COM addin
methods and properties, but none of the public variables - target, init and
size in the code below - can be accessed. When I reference the exact same
COM
from another dotnet project, the COM class public variables are all
available.

What is going on here?

I notice that I have to choose the COM addin's .tlb file, not the .dll file
in
the VBA reference dialog box. Is that expected?

Can Excel 97 VBA just not access COM class variables - or "fields" as the
dotnet documentation calls them? If so, that is going to be a serious
limitation for me.

The vb.net code of the COM addin I am using is like this:

<ComClass(fpm_goalseek_class.ClassId, _
fpm_goalseek_class.EventsId, _
fpm_goalseek_class.InterfaceId)> _
Public Class fpm_goalseek_class

Public Const ClassId As String = "6C1967B7-4EC8-4b70-BA94-C131EE892452"
Public Const InterfaceId As String =
"4CDC9471-D4E2-4824-BD4D-938EF299D58C"
Public Const EventsId As String = "4D18D7F1-BC51-49f0-824B-69F607EBD3B2"

Public target as double
Public init as double
Public size as double

' . . . Body of class code here . . .

End Class
|\|.


Nov 21 '05 #3

P: n/a
Nick Dreyer schrieb:
Thanks for the thought, however . . .

I am quite aware that properties are substitutes for exposed class variables.

I just don't know what the point of going through all the trouble of setting
up property let/set code for every single variable that needs to be accessed
outside the VB.NET class.

Are you telling me that there is no way of exposing public class variables in
VB.NET COM builds? If so what's the point of the "public" qualifier for class
variables in VB.NET?

VB.NET makes public variables visible to other VB.NET projects, why won't COM?


AFAIR, COM itself does not support public 'variables', only public methods.
If you write a COM class in VB6, public variables are also implemented as
property procedures internally.
Armin
Nov 21 '05 #4

P: n/a
On Sat, 09 Jul 2005 19:59:22 +0200, Armin Zingler <az*******@freenet.de>
wroth:
Nick Dreyer schrieb:

VB.NET makes public variables visible to other VB.NET projects, why won't COM?


AFAIR, COM itself does not support public 'variables', only public methods.
If you write a COM class in VB6, public variables are also implemented as
property procedures internally.
Armin


So I take it VB.NET does not do this. It sure would be nice if it did. A bit
of a downgrade from VB6, I'd say.

|\|.
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.