ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I create in VBA a class with instancing type different from 1 and 2? (https://www.excelbanter.com/excel-programming/281413-can-i-create-vba-class-instancing-type-different-1-2-a.html)

Dmitry V. Petkun

Can I create in VBA a class with instancing type different from 1 and 2?
 
1878026431
My application needs to use some classes that are declared in an Add-In. Can
I create in my application the objects (instances) of these classes? VBA
allows to set instancing type for a class module to 1 (Private) or 2
(PublicNotCreateable). Can I use any other instancig model in VBA?

Thanks for answers
Dmitry Petkun



Chip Pearson

Can I create in VBA a class with instancing type different from 1 and 2?
 
Dmitry,

VBA supports only Private or PublicNotCreateable classes. Therefore, your
application cannot create objects based on classes in another project. You
can add a procedure to your add-in that will create and return a new
instance of the class. For example,

' in your add-in
Public Sub CreateClassObject() As Class1
Set CreateClassObject = New Class1
End Sub

' in your application
Dim C As AddInProject.Class1
Set C = AddInProject.CreateClassObject()


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Dmitry V. Petkun" wrote in message
...
1878026431
My application needs to use some classes that are declared in an Add-In.

Can
I create in my application the objects (instances) of these classes? VBA
allows to set instancing type for a class module to 1 (Private) or 2
(PublicNotCreateable). Can I use any other instancig model in VBA?

Thanks for answers
Dmitry Petkun





onedaywhen

Can I create in VBA a class with instancing type different from 1 and 2?
 
What kind of instancing do you require?

"Dmitry V. Petkun" wrote in message ...
1878026431
My application needs to use some classes that are declared in an Add-In. Can
I create in my application the objects (instances) of these classes? VBA
allows to set instancing type for a class module to 1 (Private) or 2
(PublicNotCreateable). Can I use any other instancig model in VBA?

Thanks for answers
Dmitry Petkun



All times are GMT +1. The time now is 05:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com