Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default calling from one workbook the classes and functions in another

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling functions from dll T.K Kullervo Excel Programming 0 September 29th 03 09:55 AM
Calling Add-in functions from VBA Mark[_21_] Excel Programming 5 September 12th 03 08:49 PM
Calling certain functions within VBA Ron de Bruin Excel Programming 0 August 11th 03 10:32 PM
Calling certain functions within VBA james Excel Programming 0 August 11th 03 10:27 PM
Calling VBA functions from a xll Kim[_8_] Excel Programming 2 August 3rd 03 11:48 AM


All times are GMT +1. The time now is 08:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"