Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default referencing commandbuttons as OLEObjects

I want to be able to manipulate and get information about a large number of
commandbuttons using something like:
x = Worksheets(2).OLEObjects.Count
For b = 1 To x
xx = Worksheets(2).OLEObjects.Item(b).BackColor
Next b
This generates a error. (Although xx =
Worksheets(2).OLEObjects.Item(b).Name does not)
The only objects in the OLEObjects collection are commandbuttons.
How can I make this work?
Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default referencing commandbuttons as OLEObjects

change
xx = Worksheets(2).OLEObjects.Item(b).BackColor

to
xx = Worksheets(2).OLEObjects.Item(b).Object.BackColor
or
xx = Worksheets(2).OLEObjects.(b).BackColor

you could loop like this

dim ole as OLEObject

for each ole in Activeworkbook.Worksheets(2).OLEObjects
xx = ole.Object.Backcolor
next

By default, backcolors of OLEObjects are sytem colours, eg
vbButtonFace = -2147483633 (&H8000000F)

Regards,
Peter T

"Bert" wrote in message
...
I want to be able to manipulate and get information about a large number

of
commandbuttons using something like:
x = Worksheets(2).OLEObjects.Count
For b = 1 To x
xx = Worksheets(2).OLEObjects.Item(b).BackColor
Next b
This generates a error. (Although xx =
Worksheets(2).OLEObjects.Item(b).Name does not)
The only objects in the OLEObjects collection are commandbuttons.
How can I make this work?
Thanks.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default referencing commandbuttons as OLEObjects

Give this a try...

Sub test()
Dim ctl As OLEObject

For Each ctl In Sheet1.OLEObjects
MsgBox ctl.Object.BackColor
Next ctl
End Sub

Your code will work but it needs to refernece the object then the backcolor...
--
HTH...

Jim Thomlinson


"Bert" wrote:

I want to be able to manipulate and get information about a large number of
commandbuttons using something like:
x = Worksheets(2).OLEObjects.Count
For b = 1 To x
xx = Worksheets(2).OLEObjects.Item(b).BackColor
Next b
This generates a error. (Although xx =
Worksheets(2).OLEObjects.Item(b).Name does not)
The only objects in the OLEObjects collection are commandbuttons.
How can I make this work?
Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy commandbuttons leonidas[_51_] Excel Programming 1 July 25th 06 03:06 PM
CommandButtons Mats Samson Excel Programming 4 January 17th 06 02:19 PM
Commandbuttons PCOR Excel Programming 1 May 11th 04 11:21 PM
Do While, OnTime and CommandButtons John Petty Excel Programming 1 November 23rd 03 12:23 AM
commandbuttons properties Rui[_2_] Excel Programming 2 November 5th 03 04:07 PM


All times are GMT +1. The time now is 07:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"