ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   a command button problem (https://www.excelbanter.com/excel-programming/422223-command-button-problem.html)

NA_AB[_2_]

a command button problem
 
Range r = Connect.myApplication.ActiveCell;
Microsoft.Office.Interop.Excel.Worksheet sht =
(Microsoft.Office.Interop.Excel.Worksheet)Connect. myApplication.ActiveSheet;

Microsoft.Office.Interop.Excel.Shape btn =
sht.Shapes.AddOLEObject("Forms.CommandButton.1", Missing.Value,Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, sht.get_Range(r,
r).Left,sht.get_Range(r, r).Top,
sht.get_Range(r,r).Width, sht.get_Range(r, r).Height);


((MSForms.CommandButtonClass)btn.OLEFormat.Object) .Caption = "click_me";


Why is this not working?? How to get an event handler for this button!?


Peter T

a command button problem
 
See your earlier thread with same question

Regards,
Peter T

"NA_AB" wrote in message
...
Range r = Connect.myApplication.ActiveCell;
Microsoft.Office.Interop.Excel.Worksheet sht =
(Microsoft.Office.Interop.Excel.Worksheet)Connect. myApplication.ActiveSheet;

Microsoft.Office.Interop.Excel.Shape btn =
sht.Shapes.AddOLEObject("Forms.CommandButton.1",
Missing.Value,Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
sht.get_Range(r,
r).Left,sht.get_Range(r, r).Top,
sht.get_Range(r,r).Width, sht.get_Range(r, r).Height);


((MSForms.CommandButtonClass)btn.OLEFormat.Object) .Caption = "click_me";


Why is this not working?? How to get an event handler for this button!?





All times are GMT +1. The time now is 07:35 AM.

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