Solved

Can you index objects in VBA?

Posted on 1998-08-12
3
148 Views
Last Modified: 2010-04-30
I'm converting a standalone application into an Excel VBA application.  In the standalone, I have a series of pictures which are made visible and invisible (so as to animate).  They are Picture6(0) to Picture6(79).  However in Excel, I cannot do this because there is no index property for objects; they must be given entirely unique names.

So my question is, is indexing not allowed at all, or is it done differently that I am not aware of (as with some other small differences that I've noticed).  If it isn't allowed could you please give me some suggestions as to how I would go about doing this?

Thank you.
0
Comment
Question by:leekk
3 Comments
 
LVL 3

Expert Comment

by:dapperry
ID: 1468690
I don't think you can have a control array in VBA.  Perhaps you could call the pictures something
like PICTURE1, PICTURE2, PICTURE3, PICTURE4 - and then use something like the
eval function to refer to them.  I'm not sure of a good way to have common events amoung the objects , like a control array has, so thats why this is just a comment.

:) D Perry
0
 

Accepted Solution

by:
lstefano earned 100 total points
ID: 1468691
What about:
sub ix()
   set md = worksheets(1)
   for i=1 to md.shapes.count
      md.shapes(i).visible=false
   next i
end sub

Notice that the collection Shapes can be indexed by index and/or by name...
0
 

Author Comment

by:leekk
ID: 1468692
Thanx.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now