Using macro in Excell 2002, is there any way to use the real names of the objects inside frames?
It's really confusing when you have to use
even after naming correctly the controls.Code:Frame1.Controls.Item(1).Value
Thanks
Printable View
Using macro in Excell 2002, is there any way to use the real names of the objects inside frames?
It's really confusing when you have to use
even after naming correctly the controls.Code:Frame1.Controls.Item(1).Value
Thanks
Yes. You should be able to reference an object something like the following.You may need to provide a copy of the code to let us help you find the problem, if these kinds of statements aren't working.Code:Frame1.txtFile.Value
Frame1.opt1.Value
You may also want to try refering to the object plainly by name. Sometimes the app will know what you are refering to and not need the reference to the frame object as well. i.e.Code:txtFile.Value
opt1.Value
NatThoelecke,
thanks for your answer, but no, I cannot. I'm using Excell 2002, perhaps the problem is there ...
An example follows. The second line on the macro does not execute.
Thanks again.
I don't know if the CallByName() function is available to you, but perhaps if it is you can use that.
Wizbang,
sorry but I don't see how CallByName -yes, I have it available- sould help me in my problem.
All I want is to use a control inside a frame by its name ...
Say something so simple as
The first statement works fine. The second does not even if the button is named MyCheckBox. Simply, VB does not recognize the name of the object when it is inside a frame.Code:MsgBox (Frame1.Controls.Item(0).Value)
MsgBox (Frame1.mycheckbox.Value)
To use CallByName I have to put an object inside it ...
Thanks anyway.Code:CallByName(Frame1.Controls.Item(0), ...
' would work, but it doesn't solve my problem
So, even if you use MyCheckBox without accessing the frame, it still doesn't work? That is weird, and obviously related to VBA or excel somehow.
Suppose you place the control outside the frame at design time, and place it inside the frame at runtime, either via API or the Container property?
I'm not sure of understanding your sentence. What do you mean by "without accessing the frame"?Quote:
Originally Posted by WizBang
I'm not accessing anything. :confused:
Take a look at the code ... I just want to get the value of a property ...
Supose the checkbutton were placed outside the frame. I could do
In theory, with the button inside the frame it should beCode:MsgBox(MyCheckButton.Value)
but it does not work, VB does not recognize the name of the object.Code:MsgBox(Frame1.MyCheckButton.Value)
Well, I was trying to do something simpler than Frame1.Controls.Item(0).Value ... but moving the object at run time ... uffff :ehh:Quote:
Originally Posted by WizBang
It's just a matter of coding simplicity and clarity.
Thanks
I mean, in vb you don't need to specify the frame to get at the controls in it. I've never done that, so I don't even know if it is supposed to work. So, try just MsgBox(MyCheckButton.Value). Nevermind that it is inside a frame. Does this work?Quote:
Originally Posted by DeepButi
WizBang,Quote:
Originally Posted by WizBang
no, it does not work. And yes, you need to specify the frame. If you don't specify the frame, you are referencing objects outside the frame.
You can create two identical objects with the same name, one at the "Sheet" level and another one at the "Frame" level.
The first one's name will be, assuming it is on Sheet1, Sheet1.MyButton although you can use MyButton without qualifying it, provided the scope of the statement is adequate.
The second one's name should be Sheet1.Frame1.MyButton Again, with an appropiate scope you can use Frame1.MyButton or MyButton
The problem is ... this is in theory, because I cannot use objects inside frames using its name, I'm only able to use Frame1.Objects.Item(n)
Are you using objects inside frames? Could you post an example? In wich version of Excell/VB (I'm using Excell 2002/VB6.3) ?
Thanks a lot
In VB (not excel), there is no need to specify the frame because all the controls are seen at form level. I've never used excel, so I don't know what differences you might encounter. Suppose you create a UserControl, and expose the controls that way? Then you can create whatever methods and means of access you need.
WizBang,
yes, you're right, I work usually with VB.NET and never found such a problem, but now I'm working on that particular combination of Excell2002/VB6.3 and I'm really surprised of not "seeing" the objects anywhere. Not at the Sheet (form) level, neither at the frame level.
I'm forced to use frames because I use several sets of radio-buttons. If I put all of them at the Sheet level, they group together and only one can be selected, so I need to put each set in a separate frame.
Anyone using controls inside frames on Excell2002/VB6.3 out there? :) :)
Thanks for all your answers.
I seem to recall the forms 2.0 option buttons having a property that allowed them to be grouped without using a frame. They might come with excel, but I'm not sure. However, the forms 2.0 controls are so buggy, they are usually not worth using. Also they aren't redistributable.
I still think a UserControl would be the way I'd do this.
WizBang,
group property! of course, that's it. Stupid of me, always doing things the complex way :ehh:
That solves my problem (although how to use objects in frames by its name still remains, but I don't need it anymore).
Thanks a lot