gpt4 book ai didi

excel - VBScript 让幻象进程运行;如何摆脱它们?

转载 作者:行者123 更新时间:2023-12-04 22:09:03 25 4
gpt4 key购买 nike

我正在使用 vbscript 进行一些自动化操作,每次运行脚本时,它都会使进程“EXCEL.EXE”运行。我该如何防止呢?

代码:

Set oFs = CreateObject("Scripting.FileSystemObject")

set objExcel = createObject("Excel.Application")
set objWorkbook = objExcel.Workbooks.open("C:\test\test.xlsx")

for each sheet in objWorkbook.worksheets
wscript.echo(sheet.name)
set objSheet = sheet

next

set objSheet = Nothing
set objworkbook = Nothing
set objExcel = Nothing
Set oFs = Nothing

如何防止 EXCEL.exe 在我的脚本退出后继续运行?

最佳答案

也可以使用它来关闭 Excel。只需将 Next 之后的代码替换为以下内容。

set objSheet = Nothing
'Tells workbook to close without saving changes.
objWorkbook.Close false
set objworkbook = Nothing
'Tells Excel Application to quit.
objExcel.Quit
set objExcel = Nothing
Set oFs = Nothing

关于excel - VBScript 让幻象进程运行;如何摆脱它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13162748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com