gpt4 book ai didi

excel - 如何使用带有自动覆盖功能的 workbook.saveas

转载 作者:行者123 更新时间:2023-12-01 16:22:38 29 4
gpt4 key购买 nike

在这一段代码中,Excel总是提示:“文件已存在,是否要覆盖?”

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 总是提示我覆盖现有文件?

最佳答案

隐藏提示集xls.DisplayAlerts = False

ConflictResolution 不是 truefalse 属性,它应该是 xlLocalSessionChanges

请注意,但这与显示覆盖提示无关!

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)

关于excel - 如何使用带有自动覆盖功能的 workbook.saveas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14634453/

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