VBS not running at all

2019-08-13 11:34发布

I'm using this vbscript to trigger a macro to run in an Excel without openning the excel.

sub test()
Set fso = CreateObject("Scripting.FileSystemObject")
curDir = fso.GetAbsolutePathName(".")

Set myxlApplication = CreateObject("Excel.Application")
myxlApplication.Visible = False
Set myWorkBook = myxlApplication.Workbooks.Open("\\Mac\Home\Desktop\TEST.xlsm" ) 'Change to the actual workbook that has the Macro
myWorkBook.Application.Run "Module1.Macro1()" 'Change to the Module and Macro that contains your macro
myworkbook.save
myxlApplication.Quit
end sub

It's not working like it's supposed to, macro didn't run and even if I change the code to:

myWorkBook.Application.Run "Module1.Macro1()"

to some macro name that doesn't exist, this vbs is supposed to send me an error msg. But not even error msg shows up. Not sure why vbs is not running, I just double click the vbs file to run.

Please double note that, Even if I code anything wrong, it wont even me any error msg. Which is odd

1条回答
smile是对你的礼貌
2楼-- · 2019-08-13 12:19

I was so stupid to put sub test(), end sub in vbs, vbs does not recognize the code.

查看更多
登录 后发表回答