Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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.

--

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Accessing classes defined in another workbook

Thanks Jamie,

"onedaywhen" wrote in message
oups.com...
Bob Phillips wrote:
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


I knew that I should have been able to, and was sure that I had, but I had
forgotten how, so I went safe :-). The joy of the NGs.

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.


I don't think so. That function is in the same workbook as the class, and so
knows about the class implicitly. I juts tested again with the Instancing
property set to Private and it works fine.



BTW, why have you reverted to OneDayWhen?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Accessing classes defined in another workbook

Bob Phillips wrote:

I juts tested again with the Instancing
property set to Private and it works fine.


OK, guess number 2: your function resides in a standard module <g.
When testing, I made mine a member of ThisWorkbook and got a compile
error when the return type was a private class (solved either by
declaring the return type as Object or changing the instancing to
PublicNotCreatable).

BTW, why have you reverted to OneDayWhen?


I'm posting via google groups as usual, but since it went 'beta'
they're somehow picking up my old 'nickname'. I've updated my account
but it's still appearing in posts.
BTW why are you no longer looking over the Purbecks?

Jamie.

--

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Accessing classes defined in another workbook

"onedaywhen" wrote in message
ups.com...

OK, guess number 2: your function resides in a standard module <g.
When testing, I made mine a member of ThisWorkbook and got a compile
error when the return type was a private class (solved either by
declaring the return type as Object or changing the instancing to
PublicNotCreatable).


That must be it, mine was in a standard module. Remember that thought for
later!

I'm posting via google groups as usual, but since it went 'beta'
they're somehow picking up my old 'nickname'. I've updated my account
but it's still appearing in posts.


Don't like the new beta. Couple of good things, but I find the general
thread view less than it was, and I hate the highlighting of all selected
words. I did write and tell them the first time they tried, but they didn't
change :-)

BTW why are you no longer looking over the Purbecks?


It's winter, I can't see them! Seriously, I had to rebuild my laptop a few
weekls/months ago, and I didn't add that moniker then.



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
Accessing VBA subroutines in another workbook [email protected] Excel Programming 1 October 12th 04 12:07 AM
Accessing workbook info from a different workbook macro Brian Bowman[_3_] Excel Programming 0 September 20th 04 06:09 PM
Accessing workbook info from a different workbook macro Brian Bowman Excel Programming 2 September 16th 04 10:01 PM
calling from one workbook the classes and functions in another mark Excel Programming 5 April 22nd 04 12:06 AM
Using classes defined in an add-in Lieven Mettepenningen[_2_] Excel Programming 1 January 8th 04 03:01 PM


All times are GMT +1. The time now is 02:35 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"