Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this a Scope issue? 1

Status
Not open for further replies.

gr82btaz

Technical User
May 1, 2001
3
US
Folks,

The essence:
1. I'm instantiating an object from the code page of a sheet so I have access to
the object's events on the sheet, but...

2. I would like to use buttons on a UserForm to fire the object's member
functions, but when I try to, I get an error message saying, effectively, no
object exists (Run-time error '424': object required).

The question:
1.Is there a way to instantiate an object so that the object's events are
available to the code page of a sheet *and* the object's functions can be
accessed from a UserForm at the same time? How do I make it visible to both, if
I can?

The details:
1.I'm using Excel2000 under W98SE.

2.In the code page of the sheet I'm declaring my object variable like this:
Public WithEvents oObject As ComObject
****then later****
Set oObject = New ComObject
This launches the Object just fine. It seems from the literature and online
help, declaring *Public* should raise the scope to all modules and all projects.

3.The object is a COM/API object that I specify in Tools/References of the VBA
editor. I have no problems if I trigger its functions from command buttons on
the sheet, but I'm trying to avoid that.

4.I'm *not* using a standard module, or a class module, as these don't seem
suitable for instantiating a object.

If there's something wrong with this post, or it's just not succinct enough,
please let me know.

Chris
ih82bl8@my-deja.com
 
In the Userform try telling the code where the object is. eg.

Sheet1.oObject

When you type sheet1. the object should appear in the drop down box.
 
DarkSun,
After looking around for a way to give you feedback, and not finding anything direct, I will post an addendum here. I simply want to say, thank you very much. Your answer was exactly what I needed. It was a gap in my knowledge that I wouldn't have quickly sorted out on my own, so, again, thanks.
gr82btaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top