[英]how to use VBS run Excel Macro, but not run the Workbook_Open()
Need your help. 需要你的帮助。 I want to use vbs file to run excel macro, in the xlsm file there is Workbook_Open(), I don't want to run it, I want to run some other macro, eg, Module1.test1111
我想使用vbs文件运行excel宏,在xlsm文件中有Workbook_Open(),我不想运行它,我想运行其他宏,例如Module1.test1111
But when I open open the excel file in vbs, or run other macro directly by using below code, the Workbook_Open() will run automatically. 但是,当我在vbs中打开打开excel文件或通过使用以下代码直接运行其他宏时,Workbook_Open()将自动运行。
Please give some advice how to avoid Workbook_Open() run, thanks. 请提供一些建议,如何避免Workbook_Open()运行,谢谢。
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Visible = true
objExcel.Application.Run "'test1.xlsm'!Module1.test1111"
You do not need to specify the Application
. 您无需指定
Application
。 objExcel
is the Application
. objExcel
是Application
。 And to disable the Workbook_Open()
, switch off the events 要禁用
Workbook_Open()
,请关闭事件
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
objExcel.EnableEvents = False
objExcel.Run "'C:\Users\routs\Desktop\Sample.xlsm'!Module1.test1111"
Also remember to switch them back on ;) 还请记住将它们重新打开;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.