Selecting buttons using VBA

Bagsy

Active Member
Joined
Feb 26, 2005
Messages
467
Office Version
  1. 365
Platform
  1. Windows
Selecting buttons using VBA
Can anybody help with a small problem I have, I am trying to loop through files in a directory and add amendments. Part of this involves changing the properties of a button on a particular sheet.
The problem is, for some reason these buttons have different names ie “Button18”, “Button 51” etc.
There is only one button on this particular sheet, and I would like to be able to select it regardless of its name.
Here is what I have, but cannot get it to work

Code:
For Each Shape In ActiveSheet.Shapes
Shape.Select
    With Selection
        .Placement = xlFreeFloating
        .PrintObject = False
    End With
  Next
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi Bagsy

You did not explain why you want to select the button. To change its properties, since there is only one button on the sheet, try:

Code:
    With ActiveSheet.Buttons(1)
        .Placement = xlFreeFloating
        .PrintObject = False
    End With
 
Upvote 0
Thanks Very much Brian
Its all so easy when you know
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top