@Piyaphruk , based on my test, you could try to use the Property _oObj.Object.Value = true ;
to trigger the excel activex Button from Winform app.
Here is a code example you could refer to.
private void button1_Click(object sender, EventArgs e)
{
string xlFileName = Path.Combine("D:\\", "test1.xlsm");
var xlApp = new Excel.Application();
var xlWorkbook = xlApp.Workbooks.Open(xlFileName);
var xlSheet = xlWorkbook.Worksheets["Sheet1"] as Excel.Worksheet;
Excel.OLEObject _oObj = xlSheet.OLEObjects("CommandButton1");
_oObj.Object.Value = true ; // This code will trigger the button
xlWorkbook.Save();
xlWorkbook.Close();
Marshal.ReleaseComObject(xlWorkbook); xlWorkbook = null;
Marshal.ReleaseComObject(xlApp); xlApp = null;
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.