MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Create CommanButton in Code


Posted by Brad Smith on February 07, 2002 6:49 AM

When creating a worksheet on the fly I want to add a CommandButton. Create.Object = commandbutton isn't quite right. Any suggestions?

Thanks...Brad


Posted by Ivan F Moala on February 07, 2002 11:31 PM

ActiveX button;

ActiveSheet.OLEObjects.Add ClassType:="Forms.CommandButton.1"


Forms button

ActiveSheet.Buttons.Add Left, Top, Width, Height
eg
ActiveSheet.Buttons.Add 171, 150, 122.25, 15

HTH

Ivan

Posted by Brad Smith on February 08, 2002 7:09 AM

Thanks...Works Great.

Brad