这是我的vbs代码
CreateReport()
Private Sub CreateReport()
On Error Resume Next
If (Wscript.Arguments.Count < 3) Then
Wscript.Echo "Required Parameter missing"
Wscript.Quit
End If
strTemplate = Wscript.Arguments(0)
strReportFolder = Wscript.Arguments(1)
strReportName = Wscript.Arguments(2) Set oScriptFile = CreateObject("Scripting.FileSystemObject")
strScriptFolder = oScriptFile.GetParentFolderName(oScriptFile.GetFile(WScript.ScriptFullName)) Set oXL = WScript.CreateObject("EXCEL.application")
oXL.Visible = false
For Each AddIn In oXL.AddIns
If AddIn.Installed Then
AddIn.Installed = False
AddIn.Installed = True
End If
Next
set oWorkBook = oXL.workbooks.open(strTemplate)
oXl.DisplayAlerts = false
oXL.run "_GenerateReport"
oXL.run "_RemoveAllFormulaNow"
strDate = FormatDateTime(Date, vbShortDate)
strMonth = CStr(Month(strDate) - 1)
strYear = CStr(Year(StrDate))
if month(now)<10 then
oWorkBook.SaveAs(strReportFolder + "0" + strMonth + strYear + "_" + strReportName)
else
oWorkBook.SaveAs(strReportFolder + strMonth + strYear + "_" + strReportName)
oWorkBook.close(false) Set oXL = Nothing
oXL.quit end if
End Sub
中间有些函数是add-in的函数,现在我可以运行,可以生成excel的文件。问题是进程里面的excel杀不掉。而且运行一次,就多一个excel的进程。
有没有办法,我运行完代码直接杀掉它。谢谢。
CreateReport()
Private Sub CreateReport()
On Error Resume Next
If (Wscript.Arguments.Count < 3) Then
Wscript.Echo "Required Parameter missing"
Wscript.Quit
End If
strTemplate = Wscript.Arguments(0)
strReportFolder = Wscript.Arguments(1)
strReportName = Wscript.Arguments(2) Set oScriptFile = CreateObject("Scripting.FileSystemObject")
strScriptFolder = oScriptFile.GetParentFolderName(oScriptFile.GetFile(WScript.ScriptFullName)) Set oXL = WScript.CreateObject("EXCEL.application")
oXL.Visible = false
For Each AddIn In oXL.AddIns
If AddIn.Installed Then
AddIn.Installed = False
AddIn.Installed = True
End If
Next
set oWorkBook = oXL.workbooks.open(strTemplate)
oXl.DisplayAlerts = false
oXL.run "_GenerateReport"
oXL.run "_RemoveAllFormulaNow"
strDate = FormatDateTime(Date, vbShortDate)
strMonth = CStr(Month(strDate) - 1)
strYear = CStr(Year(StrDate))
if month(now)<10 then
oWorkBook.SaveAs(strReportFolder + "0" + strMonth + strYear + "_" + strReportName)
else
oWorkBook.SaveAs(strReportFolder + strMonth + strYear + "_" + strReportName)
oWorkBook.close(false) Set oXL = Nothing
oXL.quit end if
End Sub
中间有些函数是add-in的函数,现在我可以运行,可以生成excel的文件。问题是进程里面的excel杀不掉。而且运行一次,就多一个excel的进程。
有没有办法,我运行完代码直接杀掉它。谢谢。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货