Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Both of your solutions are appreciated as they are applicable to different circumstances.
I was unaware that I needed to first manually set a reference to the workbook that contained the methods that I want to call. Since I define - Private clsAWorker As MyLib.CWorker to explicitily reference the MyLib workbook in code - and since the workbook that i am referencing is loaded in Excel the manual reference step is not expected Thanks for your help Mark ----- Robin Hammond wrote: ---- Mark I might get corrected here, but I don't think that you can in this way. I you look at the instancing properties for your class in your source book you have 2 options, private, or publicnotcreateable. I've just played wit it and it seems that although you can create a reference to the file and th class, you can't instantiate the class What I was doing wa 1. Rename the source VBA project to MyLibs 2. Set clsAWorker to publicnotcreateabl 3. Set a reference to this project from another book 4. Try something lik Dim clsA as MyLibs.clsAWorker 'this work Set clsA = new MyLibs.clsAWorker 'this fail Instead, there is an option if you have VB Copy your cls into a VB Project for an activex dll. Set the class instancin property to MultiUse. Create the dll. Set a reference to your dll from you excel file, and the class can now be created as normal and referenced by an file you want. You should also set project binary compatability in the v project so that if you recompile the dll you don't have to reset th reference every time in Excel HTH Robin Hammon www.enhanceddatasystems.co "mark" wrote in messag .. I have a workbook loaded (mylibs.xls) that may become an add in. I als have another workbook loaded (mywork.xls) that would like to use classes an public methods defined in mylibs mylibs contains models and classes and defines such items as Public aworker As clsAWorker (clsAWorker is defined in mylibs Public helpfulList As Scripting.Dictionar Public function doSomething(arg1 as integer) as integer {... (defined in a mylibs module From within mywork I want to access the public items of mylibs but when try to reference the items the VBA pre-processor errors out. How do yo refence and use VBA objects in an external workbook Thank |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calling functions from dll | Excel Programming | |||
Calling Add-in functions from VBA | Excel Programming | |||
Calling certain functions within VBA | Excel Programming | |||
Calling certain functions within VBA | Excel Programming | |||
Calling VBA functions from a xll | Excel Programming |