如何使用 workbook.saveas 自动覆盖 [英] How to use workbook.saveas with automatic Overwrite
本文介绍了如何使用 workbook.saveas 自动覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这一段代码中,Excel总是提示:文件已经存在,要覆盖吗?"
In this section of code, Excel ALWAYS prompts: "File already exists, do you want to overwrite?"
Application.DisplayAlerts = False
Set xls = CreateObject("Excel.Application")
Set wb = xls.Workbooks.Add
fullFilePath = importFolderPath & "" & "A.xlsx"
wb.SaveAs fullFilePath, AccessMode:=xlExclusive, ConflictResolution:=True
wb.Close(True)
如果我有 DisplayAlerts = False
,为什么 db.SaveAs
总是提示我覆盖现有文件?
Why does db.SaveAs
always prompt me to overwrite existing file if I have DisplayAlerts = False
?
推荐答案
隐藏提示设置 xls.DisplayAlerts = False
ConflictResolution
不是 true
或 false
属性,它应该是 xlLocalSessionChanges
ConflictResolution
is not a true
or false
property, it should be xlLocalSessionChanges
注意这与显示覆盖提示无关!
Note that this has nothing to do with displaying the Overwrite prompt though!
Set xls = CreateObject("Excel.Application")
xls.DisplayAlerts = False
Set wb = xls.Workbooks.Add
fullFilePath = importFolderPath & "" & "A.xlsx"
wb.SaveAs fullFilePath, AccessMode:=xlExclusive,ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges
wb.Close (True)
这篇关于如何使用 workbook.saveas 自动覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文