|
-
Apr 30th, 2005, 05:30 PM
#1
Thread Starter
New Member
[Rsolved]Inaccessible class module
Here's my problem. I'm using VBA in Excel, running under Windows 2000. I wrote a class module and placed it in a project (workbook) which also contains a bunch of other utilities. I wrote a stub program to call the methods of the class in order to test the output, and saved it alone in a separate module in the same project. I can run the stub subroutine and it calls each of the four methods in turn and retrieves the correct results. However, when I copied the stub module verbatim into another project, I got a compile error saying "User-defined type not defined". I placed a reference to the project containing the class module in the project from which I want to call the class's methods. That didn't help. I used the object browser to look at the class module and found that it required a reference to Microsoft VBA Extension 5.1. I placed a reference to Microsoft VBA Extension 5.1 in the problem project. That didn't help either.
I'm starting to suspect that the problem may be some type of security setting which keeps the class module from being accessible to another project. Keep in mind that the two stub modules are identical. The object is instantiated identically in each, and then all of its methods are called one at a time. The only difference is that one is in the same project as the class module and the other isn't. And the first one works, and the second one doesn't. Anybody have any insight into this?
Last edited by Querent; May 9th, 2005 at 02:04 AM.
Reason: Resolved
-
May 3rd, 2005, 07:53 AM
#2
Re: Inaccessible class module
Is the class module public?
Are they both opened in Excel? The same Application and not different Applications (can sometimes not let you run code)..?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 4th, 2005, 04:53 AM
#3
Thread Starter
New Member
Re: Inaccessible class module
Hi Ecniv. Further research has revealed that I was mistaken in my expectations of how these class modules are supposed to act. They do in fact have to be copied to another project before they are accessible to that project. I don't care for this fact too much. It seems to partially nullify the idea of fixing the code contained in a class module only once to fix it in all its instances. The references I have been consulting tell me that the classes can be made accessible across project lines by converting the class module into an Active-X component. This particular one probably doesn't merit that treatment. So please excuse me for wasting your time on a misbegotten question. Thanks for attempting to help, though!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|