ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Removing Command Button (https://www.excelbanter.com/excel-programming/290292-removing-command-button.html)

SS[_3_]

Removing Command Button
 
I am having a terrible time getting my command buttons to
work.

It does not seem to even recognize my Click event.

Sub A()

ActiveSheet.OLEObjects.Add
(ClassType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=300, Top:=250,
Width:=125, Height:= _
50).Select

ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption
= "Run Me"

End Sub

Sub CommandButton1_Click()
ActiveSheet.OLEObjects("CommandButton1").Object.Vi sible =
False
End Sub

Any Suggestions?

Thanks

SS

Bob Phillips[_6_]

Removing Command Button
 
Is the click event code in the worksheet code module.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"SS" wrote in message
...
I am having a terrible time getting my command buttons to
work.

It does not seem to even recognize my Click event.

Sub A()

ActiveSheet.OLEObjects.Add
(ClassType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=300, Top:=250,
Width:=125, Height:= _
50).Select

ActiveSheet.OLEObjects("CommandButton1").Object.Ca ption
= "Run Me"

End Sub

Sub CommandButton1_Click()
ActiveSheet.OLEObjects("CommandButton1").Object.Vi sible =
False
End Sub

Any Suggestions?

Thanks

SS





All times are GMT +1. The time now is 09:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com