473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VBA does not see public class variables in COM addin

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
4 2451
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jaime Rios | last post by:
Hi, I created a COM AddIn for Word that performs the functions that it needs to, but I needed to add the ability for the toolbar created by the COM AddIn to remember it's last position and...
0
by: Robert | last post by:
I want to disable Class view by an Addin VS.net 2003 How do I do that... In VS 6 there was an registry entry that could disable the class view... I know how to disable the class view for the VS7...
3
by: nicver | last post by:
I am fixing a client's Web site and for some reason an ASP class does not want to use the variables it retrieves when it initialiases. This is an excerpt of the class and it is enough to show...
6
by: darrel | last post by:
I'm still not quite sure how best to handle the passing of data between controls. This is a method I'm using at the moment: I have an XML file that contains a variety of page-centric...
10
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public...
7
by: Joseph Geretz | last post by:
I've been working on an Addin for Outlook in C#. It hasn't been long now, just a couple of days. Suddenly though, running my project in Debug launches Outlook as specified, but no breakpoints...
2
by: Jim M | last post by:
I rarely deal with recordsets directly with code, since I usually use Access queries, so be patient with this question. I want to open a recordset with various default variables used by my program....
6
by: Christof Nordiek | last post by:
Hi, I created an Addin Project with the Addin-Project-Wizzard in VS2005. I added some code from a Knowledge Base How To und built the project. It worked, and the Addin got registered with...
0
by: Jon | last post by:
Hello all, I recently posted a question about a tool that would create the public member variables for a selected set of private member variables - when there's 10 - 15 privates, it can be very...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.