dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Objects names in frames

Hybrid View

  1. #1
    Join Date
    Dec 2003
    Location
    St. Cugat - Catalunya
    Posts
    441

    Objects names in frames

    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
    Code:
    Frame1.Controls.Item(1).Value
    even after naming correctly the controls.

    Thanks
    Did it help? rate it.

    The best conversation I had was over forty million years ago ... and that was with a coffee machine.

  2. #2
    Join Date
    Jan 2004
    Location
    San Diego
    Posts
    148

    Re: Objects names in frames

    Yes. You should be able to reference an object something like the following.
    Code:
    Frame1.txtFile.Value
    Frame1.opt1.Value
    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.

    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
    Last edited by NatThoelecke; September 22nd, 2005 at 12:56 PM. Reason: Thought of something else that might help
    Death is life's special way of telling you you're fired.

    For I do not seek to understand in order to believe, but I believe in order to understand. For I believe this: unless I believe, I will not understand. - Anselm of Canterbury (10331109)

  3. #3
    Join Date
    Dec 2003
    Location
    St. Cugat - Catalunya
    Posts
    441

    Re: Objects names in frames

    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.
    Attached Files Attached Files
    Did it help? rate it.

    The best conversation I had was over forty million years ago ... and that was with a coffee machine.

  4. #4
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Objects names in frames

    I don't know if the CallByName() function is available to you, but perhaps if it is you can use that.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  5. #5
    Join Date
    Dec 2003
    Location
    St. Cugat - Catalunya
    Posts
    441

    Re: Objects names in frames

    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
    Code:
    MsgBox (Frame1.Controls.Item(0).Value)
    MsgBox (Frame1.mycheckbox.Value)
    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.

    To use CallByName I have to put an object inside it ...
    Code:
    CallByName(Frame1.Controls.Item(0), ...
        ' would work, but it doesn't solve my problem
    Thanks anyway.
    Did it help? rate it.

    The best conversation I had was over forty million years ago ... and that was with a coffee machine.

  6. #6
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Objects names in frames

    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?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)