share class modules

flyerStarter

New Member
Joined
Mar 2, 2004
Messages
1
Hi to all.

I have 2 excel files which contain similar functions and class modules.
So I created a third file which contains these similar objects and next added a reference in the 2 files to this third file. No problem for "normal modules" but for classes modules".

I tried to find some informations but found nothing, except creating a dll file.
Isn't it possible to add class modules in my third file ?

Thkx for your answer.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
Yes, it is.

Change the Instancing property to 'PublicNotCreatable'.

Now, in the third book, you need to create some functions to create the class modules, and return a reference for the other books. It's basically like using late binding...

Something like

Code:
Function NewClass1() As Class1
    Set NewClass1 = New Class1
End Function

and in the other books you use stuff like

Code:
Sub Test()
  Dim myClass As Object
  Set myClass = NewClass1()
  'Do stuff with myClass
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,094
Messages
5,768,051
Members
425,451
Latest member
JohnBrooksBiddle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top