ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SaveAs defaults... (https://www.excelbanter.com/excel-programming/333313-saveas-defaults.html)

John Keith[_2_]

SaveAs defaults...
 
Using this code to save when the file already exists...

Logfile = "filename.xls"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=CurDir() & "\" & Logfile,
ConflictResolution:=xlLocalSessionChanges
Application.DisplayAlerts = True

How do you know which default (yes|no) is taken to the overwrite message?
I assume from all the posts I have seen on this topic that the "yes" default
is taken, but what if you wanted the "no" option taken?

The parm for "ConflictResolution" seems like that should handle it, but the
options shown in the help files do not cover this.

--
Regards,
John

Tom Ogilvy

SaveAs defaults...
 
If you want to not overwrite the file, then test for its existence and do
not execute the save

Logfile = "filename.xls"
if Dir(curdir() & "\" & logfile) = "" then
ActiveWorkbook.SaveAs Filename:=CurDir() & "\" & Logfile,
Else
msgbox "File conflict"
End if

--
Regards,
Tom Ogilvy

"John Keith" wrote in message
...
Using this code to save when the file already exists...

Logfile = "filename.xls"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=CurDir() & "\" & Logfile,
ConflictResolution:=xlLocalSessionChanges
Application.DisplayAlerts = True

How do you know which default (yes|no) is taken to the overwrite message?
I assume from all the posts I have seen on this topic that the "yes"

default
is taken, but what if you wanted the "no" option taken?

The parm for "ConflictResolution" seems like that should handle it, but

the
options shown in the help files do not cover this.

--
Regards,
John





All times are GMT +1. The time now is 03:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com