Button Object

Description

Represents a custom button graphic object on a chart sheet, dialog sheet, or worksheet. Do not confuse the Button object with the ToolbarButton object, which is a button on a toolbar.

Accessors

The Button object is a member of the Buttons collection. The Buttons collection contains all the Button objects on a single sheet. Use the Add method to create a new button and add it to the collection.

To access a single member of the collection, use the Buttons method with the index number or name or of the button as an argument.

The following example sets the text for button one on the worksheet named "Sheet1."


Worksheets("sheet1").Buttons(1).Text = "Repeat"

The button name is shown in the Name Box when the button is selected. Use the Name property to set or return the name of the button. The following example positions the button named "go_button" so that it completely cover cell C10. When the button is pressed, the GoButtonTest macro runs.


Worksheets("sheet1").Activate
Set r = ActiveSheet.Range("c10")
With ActiveSheet.Buttons("go_button")
    .Caption = "Go"
    .Left = r.Left
    .Top = r.Top
    .Width = r.Width
    .Height = r.Height
    .OnAction = "GoButtonTest"
End With

Properties

Accelerator Property, AddIndent Property, Application Property, AutoSize Property, BottomRightCell Property, CancelButton Property, Caption Property, Creator Property, DefaultButton Property, DismissButton Property, Enabled Property, Font Property, Formula Property, Height Property, HelpButton Property, HorizontalAlignment Property, Index Property, Left Property, Locked Property, LockedText Property, Name Property, OnAction Property, Orientation Property, Parent Property, PhoneticAccelerator Property, Placement Property, PrintObject Property, Text Property, Top Property, TopLeftCell Property, VerticalAlignment Property, Visible Property, Width Property, ZOrder Property.

Methods

BringToFront Method, Characters Method, CheckSpelling Method, Copy Method, CopyPicture Method, Cut Method, Delete Method, Duplicate Method, Select Method, SendToBack Method.