打开拖放Excel文件w/.vbs并应用VBA宏
尝试打开一个Excel文件,将其拖放到.vbs脚本上,如下所示:打开拖放Excel文件w/.vbs并应用VBA宏,excel,vba,vbscript,Excel,Vba,Vbscript,尝试打开一个Excel文件,将其拖放到.vbs脚本上,如下所示: Wscript.echo "Begin..." Set objArgs = Wscript.Arguments dropped file Wscript.echo "The file name you dropped is:" & objArgs(0) CreateObject("WScript.Shell").Run "objArgs(0)" Wscript.echo "...Finished" 导致错误的行是
Wscript.echo "Begin..."
Set objArgs = Wscript.Arguments dropped file
Wscript.echo "The file name you dropped is:" & objArgs(0)
CreateObject("WScript.Shell").Run "objArgs(0)"
Wscript.echo "...Finished"
导致错误的行是CreateObject(“WScript.Shell”)。运行“objArgs(0)”
如何使vbs代码打开它,然后将宏应用于该Excel文件?删除引号:
CreateObject(“WScript.Shell”)。运行objArgs(0)
o=CreateObject(“Excel.application”):o.workbooks.open(objArgs(0)):o.Run“macro”
它可以工作。但是是否有一种方法将VBA代码应用到这个打开的工作表上?打开一个有你想要运行的宏的工作簿,然后调用它使用<代码> ObjExcel。运行< /COD> -查看或者如果宏不是很复杂,你可以考虑把它转换成VBScript。