如何使用自动覆盖的workbook.saveas [英] How to use workbook.saveas with automatic Overwrite
本文介绍了如何使用自动覆盖的workbook.saveas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在本节代码中,Excel ALWAYS提示:文件已存在,是否要覆盖?
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)
为什么 db.SaveAs
总是提示我覆盖现有文件,如果我有 DisplayAlerts = False
?
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屋!
查看全文