Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Accessing VBA subroutines in another workbook | Excel Programming | |||
Accessing workbook info from a different workbook macro | Excel Programming | |||
Accessing workbook info from a different workbook macro | Excel Programming | |||
calling from one workbook the classes and functions in another | Excel Programming | |||
Using classes defined in an add-in | Excel Programming |