Hi, For our developpement , I want to create an utility VBA project , inside this project creating some class modules. From others projects , how can I dynamicaly create objects referencing one one the class in the utility project ? (the NEW instruction can't access to a module outside the current project) Thanks -- Cesi2d Luc Vallot Chemin du Bassard 38121 Chonas l ' amballan France Tel: 04 74 58 95 68
Create a function in a standard module of the class' project that creates a new instance of the object and returns the object. Search this ng for recent posts on reusing code for more details if you need them. -- R. Robert Bell Hi, For our developpement , I want to create an utility VBA project , inside this project creating some class modules. From others projects , how can I dynamicaly create objects referencing one one the class in the utility project ? (the NEW instruction can't access to a module outside the current project) Thanks -- Cesi2d Luc Vallot Chemin du Bassard 38121 Chonas l ' amballan France Tel: 04 74 58 95 68
You can sort of. In the Utility project: -Set the Instancing property of the classes to Public NotCreatable. (Unfortunately you don't have the option of simply Public, so it won't work directly with NEW in another project, but....) - Add a module with the function NewMyClass that returns a new copy of the class. - You will want to change the project name to something other than the default name of ACADProject. ie. change it to Utility or somthing similar. In the other projects: - Make sure References (under tools References) has the utility project checked. - Now you can simply do: Set ob = NewMyClass or Set ob = Utility.NewMyClass -Tim