View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
onedaywhen[_2_] onedaywhen[_2_] is offline
external usenet poster
 
Posts: 74
Default Accessing classes defined in another workbook

Bob Phillips wrote:


Public Function CreateClass1() As clsClass1
Set CreateClass1= New clsClass1
End Function

You need to use a generic object type as the class
object is not known in that workbook


If the class's Instancing property is changed to PublicNotCreatable
then it is known and can be declared as the class type e.g.

Dim myClass As VBAProject.clsClass1

where VBAProject is the name of the VBA project to which the reference
has been set (optional but recommended).

In fact, I think the class in your example must already be
PublicNotCreatable, otherwise I think you would have to declare the
return type of your CreateClass1 function as Object.

Jamie.

--