Casting variables

Harvey

Well-known Member
Joined
Nov 18, 2004
Messages
953
Simple question, but yet I found no answer.

I have a function that returns an object. The object is of the class clsCompany, but it is returned as Object. I can access all the values and functions in it, but I would like to store it in a clsCompany variable again. How can I do that?
 
Hi people,

Tushar,
I have tried your solution but when I try to set a class to publicnotcreatable I get an error 380: "Invalid property value."
Also, I cannot think of any way to copy the data when I have the class modules in both workbooks, since I am using a lot of Collections. While I can seem to cast the supermanager by putting it into a collection before exporting, every other instance of any class that is inside a collection is cast to (Object) automatically. I am really stuck here. Should I post my code?

Greg,
Have you fixed your problem already? I have had similar problems when I created OLEObjects in a worksheet.

Thanks for all the comments and help so far,
Regards,

Martien
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,215,507
Messages
6,125,212
Members
449,214
Latest member
mr_ordinaryboy

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
Back
Top