ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save as, not overwrite (https://www.excelbanter.com/excel-programming/390253-save-not-overwrite.html)

Carlee

Save as, not overwrite
 
Hi there,

The following code saves the spreadsheet in question, overwriting any
existing with the same name, that is found on the Desktop.

Question:
How can i change this code such that it prompts me to Save As, rather than
overwrite?

Any help is appreciated greatly,

pathToUserDesktop = "C:\Documents and Settings\" & _
Get_Win_User_Name() & "\Desktop\" & newWorkbookName
'save new workbook, but don't nag
'user with "file exists" message
Application.DisplayAlerts = False
With Workbooks(destBook)
'renames it while saving it
'will overwrite existing file of same name
.SaveAs pathToUserDesktop
'close it
.Close
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True

--
Carlee

Trevor Shuttleworth

Save as, not overwrite
 
Suggest you remove:

Application.DisplayAlerts = False

The code *is* doing a Save As ... you just choose to allow it to overwrite
an existing file.

Regards

Trevor


"Carlee" wrote in message
...
Hi there,

The following code saves the spreadsheet in question, overwriting any
existing with the same name, that is found on the Desktop.

Question:
How can i change this code such that it prompts me to Save As, rather than
overwrite?

Any help is appreciated greatly,

pathToUserDesktop = "C:\Documents and Settings\" & _
Get_Win_User_Name() & "\Desktop\" & newWorkbookName
'save new workbook, but don't nag
'user with "file exists" message
Application.DisplayAlerts = False
With Workbooks(destBook)
'renames it while saving it
'will overwrite existing file of same name
.SaveAs pathToUserDesktop
'close it
.Close
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True

--
Carlee





All times are GMT +1. The time now is 04:54 PM.

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