Class Module Scope

  • Thread starter Thread starter Trent Argante
  • Start date Start date
T

Trent Argante

Howdy All,
Is it possible to create an object from a class module in
another workbook. I created a reference to the other
workbook, but that didn't do the trick.
TIA
Trent
 
Trent,

You can change the instancing property of the class to "Public
Not Creatable" which will allow you to declare a variable of that
class type, but not create an instance of the class. In the
project that contains the class, create a public function in a
standard code module that create a new instance of the class and
returns a reference as its result.

For example,
' in the project that contains Class1
Public Function CreateClass () As Class1
Set CreateClass = New Class1
End Function

' in the project that need a Class1 variable
Dim C1 As ProjName.Class1
Set C1 = ProjName.CreateClass()


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