Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Collections (VBA/Powerpoint/2000)

    Hi everyone.

    I was wondering if someone could give me a few pointers regarding Collections?

    I'm working with a form that has lots of Command Buttons on it, and I'm wanting to get them to disappear or appear, depending on the users selection. I can do this quite easily by referring them individually, but this seems to be quite cumbersom. i.e.

    If CommandButton1.Value = True Then
    CommandButton2.Visible = False
    CommandButton3.Visible = False
    Etc. etc.

    Am I right in thinking that I could group a specified range of buttons into a collection and then refer to that?

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Collections (VBA/Powerpoint/2000)

    Not quite what you asked, but if the controls are named as in your example, you can use code like this:

    Dim i As Integer
    For i = 1 To 20
    Me.Controls("CommandButton" & i).Visible = False
    Next i

    or

    Dim i As Integer
    For i = 1 To 20
    Me.Controls("CommandButton" & i).Visible = Not (i = 5)
    Next i

    etcetera.

    BTW what is the value of a command button?

  4. #3
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Collections (VBA/Powerpoint/2000)

    opps my fault!! I was working with Toggles all yesterday, which obviously have a value!! Thanks for spotting that hans

  5. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Collections (VBA/Powerpoint/2000)

    Collections are wonderful! I have traded in arrays for collections. No more ReDim's <img src=/S/joy.gif border=0 alt=joy width=23 height=23> <img src=/S/exclamation.gif border=0 alt=exclamation width=15 height=15> Plus you can access the items by number (1-based) or by name. I program GIS (geographic information systems) and have one routine that collects stuff and then other routines that modify the items in the collection (move, colorize, sort, group, etc). See attached workbook for a silly example along the lines that you want.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  6. #5
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Collections (VBA/Powerpoint/2000)

    Opps, just noticed that you are doing PowerPoint. I can make an example in PoPo if you give me some idea of what you want to do. HTH --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Posting Permissions

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