Sub RunCommandButton3_Click() Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook

'打开本地的Excel文件
Set xlApp = New Excel.Application
Set xlWorkBook = xlApp.Workbooks.Open('C:\Users\Username\Desktop\Test.xlsx')

'运行CommandButton3_Click函数
xlApp.Run 'Test.xlsx!Sheet1.CommandButton3_Click'

'关闭Excel文件并释放对象
xlWorkBook.Close False
xlApp.Quit
Set xlWorkBook = Nothing
Set xlApp = Nothing

End Sub

VB代码:自动运行Excel文件中的按钮点击事件

原文地址: https://www.cveoy.top/t/topic/ovkH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录