What is correct syntax for a CommandButton?

L

Les

Hi

I can't seem to understand the method to change a .Shadow property
of a series of CommandButtons on different sheets.

I am trying by using a For...Next loop, cycling through the sheets
and for each CommandButton3 on the sheet - set or unset the button
shadow depending on other factors.

I have tried all sorts, but as usual, obviously not the correct
way.

i.e. WorkSheets(i).Shapes("CommandButton3").Shadow = True (or
False) doesn't work!

Buy you a pint next time I see you.

regards,
 
M

Matthew Connor

Les said:
Hi

I can't seem to understand the method to change a .Shadow property
of a series of CommandButtons on different sheets.

I am trying by using a For...Next loop, cycling through the sheets
and for each CommandButton3 on the sheet - set or unset the button
shadow depending on other factors.

I have tried all sorts, but as usual, obviously not the correct
way.

i.e. WorkSheets(i).Shapes("CommandButton3").Shadow = True (or
False) doesn't work!

Buy you a pint next time I see you.

regards,

There are two different types of buttons you can easily put onto
worksheets. One type comes from the Forms toolbar (default name
'Button 1'), the other comes from the Control Toolbox (default name
'CommandButton1').

Forms use the Shapes collection - Control Toolbox use the OLEObjects
collection.

Try:
WorkSheets(i).OLEObjects("CommandButton3").Shadow = True

If you are modifing many properties (or want to explore with
intellisense) you could use:
Dim btn as CommandButton
btn = WorkSheets(i).OLEObjects("CommandButton3").Object
btn.Shadow = True


Regards,

Matthew Connor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top