我正在尝试从vbs脚本打印文件,但下标超出范围。从excel运行时,宏的效果很好。
VBS脚本是:
dim xlApp
Set xlApp = CreateObject("Excel.Application")
xlApp.Application.Run "'C:\Users\jporter8\Documents\dashboard\testing.xlsm'!Module1.print_Test"
xlApp.DisplayAlerts = True
xlApp.Application.quit
set xlApp = Nothing
而excel宏是:
Sub print_Test()
Sheets("two").PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
MsgBox "Print successful"
End Sub
我要打印的工作表名为“两个”
答案 0 :(得分:0)
我发现此工作可以打开工作簿,以便工作表存在并且不在范围内
dim xlApp, xlBook
Set xlApp = CreateObject("Excel.Application")
set xlBook = xlApp.Workbooks.open("C:\Users\jporter8\Documents\dashboard\testing.xlsm", 0, true)
xlApp.Run "Module1.print_Test"
xlApp.DisplayAlerts = True
wscript.echo "Printed"
xlBook.Close
xlApp.Quit
set xlApp = Nothing
set xlBook = Nothing
wscript.echo "Finished"
wscript.Quit