vbs打印本地文件代码
Dim XL
Dim XLWkbk
Dim fso, fullPathToZip
set fso = CreateObject("Scripting.FileSystemObject")
fullPathToZip = fso.GetFile(Wscript.ScriptFullName).ParentFolder.Path + "\printTemp.xlsx"
Set XL = CreateObject("excel.application")
XL.Visible = True
Set XLWkbk = XL.Workbooks.Open(fullPathToZip)
XLWkbk.ActiveSheet.PrintPreview
XLWkbk.Close False
XL.Quit
Set XLWkbk = Nothing
Set XL = Nothing
NodeJs调用vbs脚本
// 获取vbs路径
let updateDotExe = path.resolve(exePath, '', 'print/print.vbs');
// 获取子进程
let cp = require('child_process');
// 执行指令
let child = cp.exec(updateDotExe, error => {
// 意外
});
child.on('close', (code) => {
// 结束
});