如何在没有提示的情况下从 VBScript 关闭 Excel 文件? [英] How to Close Excel file from VBScript without being prompted?

查看:34
本文介绍了如何在没有提示的情况下从 VBScript 关闭 Excel 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 VB 脚本,它可以打开一个 Excel 文件并运行一个宏.我试图在没有提示保存的情况下关闭这个 excel 文件(不保存任何更改).我已将已保存"属性设置为 true.但我仍然提示保存窗口.我在某处读到我必须禁用宏.不确定如何?我想在不保存和提示的情况下关闭 excel 文件.

I have a VB Script that opens an Excel file and runs a macro. I am trying to close this excel file(without saving any changes) without being prompted to save. I have set the 'Saved' property to true. But I am still prompted with the Save window. I read somewhere that I have to disable the macro. Not sure how? I would like to close the excel file without saving and without prompting.

Dim objExcel, objWorkbook 

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("c:\aaa\Test.xls")
objExcel.Visible = True
objExcel.Run "Extract_PLStatements"
objworkbook.Saved = True
objWorkbook.Close

objExcel.Quit

Set objWorkbook = Nothing
Set objExcel = Nothing

WScript.Quit

推荐答案

应该这样做:

objExcel.DisplayAlerts = False

objWorkbook.Close False 

这篇关于如何在没有提示的情况下从 VBScript 关闭 Excel 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆