+ Reply to Thread
Results 1 to 3 of 3

Question about passing array of objects in between subs

  1. #1
    Registered User
    Join Date
    02-12-2014
    Location
    Amsterdam, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question Question about passing array of objects in between subs

    Hello! I am having trouble passing an array of objects to a subsequent sub.

    I want to do the following. Sub 1 works fine, but sub 2 does not. Both are activeX buttons.
    1. Sub 1: Create 5 activeX option buttons in the worksheet
    2. Sub 1: Construct an array, each array element containing one of the option button objects
    3. Sub 2: Goes through the array and see which one is selected

    Sub 1
    Please Login or Register  to view this content.
    here's the problematic part
    Please Login or Register  to view this content.
    I have three questions
    1. Will the oleObj() argument be accessible? And how do I pass it if the sub is called by a button
    2. If executed from VBA, error results (as if the variable isn't there)
    3. I can't check the actual function, is obj.object.value=1 the correct way of checking whether a radio button is pressed?

    Thank you so much in advance, and sorry if the question is really dumb

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Question about passing array of objects in between subs

    Hello timtianchen,

    Welcome to the Forum!

    Sorry to say it is not that easy. To do what you want requires using a technique known as Sub-Classing. This allows you to extend and ActiveX controls properties. I have attached an example workbook for you.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-12-2014
    Location
    Amsterdam, the Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Question about passing array of objects in between subs

    Hey, thanks for your quick reply. This is a lot more complicated than I thought! I will go through the code now, but is this the best way / only way to parse through user selections? I am trying to convert a web application into excel, and it seems daunting.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Question about passing array to subroutine......
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2012, 08:19 PM
  2. Passing a variable through several Subs/Functions
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-02-2011, 11:32 AM
  3. Passing variables between subs?
    By jerseyguy1996 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-03-2009, 03:26 PM
  4. Passing UDTs to subs
    By PeterWilliams in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2009, 04:45 PM
  5. Passing the value of listbox to other Subs
    By Cygnus241 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2005, 01:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1