View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Create a collection of controls

Quartz,

Try the following code

Dim colObject As New Collection
Dim vItem As Variant
Dim oItems As OLEObjects
Dim lX As Long

Set oItems = ActiveSheet.OLEObjects
For Each vItem In oItems
lX = lX + 1
colObject.Add vItem, Format(lX, "0")
Next


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"quartz" wrote in message
...
I am using Office 2003 on Windows XP.

I have several controls on a spreadsheet (non-ActiveX controls)
and I want
to add these objects to a collection. How do I do this? What I
have so far
follows, but ofcourse generates an error:

Dim colObject As New Collection
Dim vItem As Variant
Dim oItems As Controls
Dim lX As Long

Set oItems = ActiveSheet.Controls
For Each vItem In oItems
lX = lX + 1
colObject.Add vItem, lX
Next

Could someone please correct my code or supply example code on
how to do
this? Thanks much in advance.