Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Commandbutton questions 1

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
523
US
Hi guys;

I'm having some bad brain farts today and cannot remember the way to add a command button to an Excel Sheet via VBA. I can generate the button, but I can not name it, change properties, or assign it to call another macro when pressed.

The button properties that need to be in place are as follows:

Button name = printbutton
caption = PRINT
font.bold = true
on press run macro = printmacro

I tried using the help file and the auto macro recorder, but it would not capture the properties not the assignment of the macro.

Thank you for the help
 




Hi,

Is this a Form control or a Control Toolbox control?

Have you tried recording a macro?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,

Yes, I have tried to record the macro with all of the properties and all I get is this:

Code:
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
        , DisplayAsIcon:=False, Left:=66.75, Top:=83.25, Width:=96.75, Height _
        :=25.5).Select


Thanks
 




Code:
    With ActiveSheet.Buttons.Add(68.25, 51, 138.75, 47.25)
        .Name = "printbutton"
        .Caption = "PRINT"
        .Font.Bold = True
        .OnAction = "printmacro"
   End With

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
worked great buddy. Thank you. I was going i n circles on this one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top