VBS根本没有运行 [英] VBS not running at all

查看:149
本文介绍了VBS根本没有运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  sub test( )
设置fso = CreateObject(Scripting.FileSystemObject)
curDir = fso.GetAbsolutePathName(。)

设置myxlApplication = CreateObject(Excel.Application)
myxlApplication.Visible = False
设置myWorkBook = myxlApplication.Workbooks.Open(\\Mac\Home\Desktop\TEST.xlsm)'更改为具有宏的实际工作簿
myWorkBook.Application.RunModule1.Macro1()'更改为包含宏的模块和宏
myworkbook.save
myxlApplication.Quit
end sub

它不会像原来那样工作,宏没有运行,即使我将代码更改为: p>

  myWorkBook.Application.RunModule1.Macro1()

到一些不存在的宏名称,这个vbs应该给我发一个错误msg。但是甚至没有错误msg出现。不知道为什么vbs没有运行,我只是双击vbs文件运行。



请双击,
即使我的代码错了,它wnt甚至我任何错误msg。这是奇怪的

解决方案

我非常愚蠢地把sub test(),end子进入vbs,vbs不能识别代码。


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

解决方案

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

这篇关于VBS根本没有运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆