LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default SaveAs error handling

Here is the problem...I tell the workbook where to save and with what name
using code, part of the file name is a date entered by the user. If the user
enters the same date then I want to give them the option of overwriting the
file or canceling the save. I have tried the following code and can't get it
to work properly. It works great if I put in Application.DisplayAlerts =
False and just allow it to overwrite the existing file, but if there is
already a lot of info in that file that would not be good. I would like it to
be a critical message and they can either choose yes or no, if they choose
yes then it would resume the save, if no then I will put some code in so that
certain sheets are shown. Any help is greatly appreciated.

On Error GoTo SaveOrNot

ActiveWorkbook.SaveAs Filename:= _
myFileName, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

MsgBox "File Saved to " & myFileName
End If
Application.ScreenUpdating = True

SaveOrNot:
Dim Res As Long
Res = MsgBox("A File With This Name Already Exists In This Location! Do You
Want To Replace It?", vbYesNo)
If Res = 6 Then
Resume
ElseIf Res = 7 Then
End If
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Handling JT Excel Programming 1 April 6th 06 03:20 PM
VBA: Error handling [email protected] Excel Programming 0 March 21st 06 09:28 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Error Handling Rob Bovey Excel Programming 0 August 7th 03 12:11 AM


All times are GMT +1. The time now is 07:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"