Try adding IgnoreReadOnlyRecommended:=True
Set wbConn = AppExcel.Workbooks.Open("YourFilePath", True, False, IgnoreReadOnlyRecommended:=True)
If it does not work try directly:
Set wbConn = AppExcel.Workbooks.Open("YourFilePath", True, IgnoreReadOnlyRecommended:=True)
Another additional solution would be to always .SaveAs
the file instead of using .Save
for which you could change the name of your file or use ConflictResolution
to overwrite the existing file
.SaveAs Filename:="YourFilePath", ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges
I suggest you add AppExcel.DisplayAlerts = False
to the beginning of your code if you want to avoid the prompt messages that overwriting the file could cause
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…