VBA Error when Saving an existing file

D

donh

Hi Folks,

I got help with this before Christmas


With ActiveWorkbook
.SaveAs Filename:="" _
& .Worksheets("sheet1").Range("A3").Value _
& .Worksheets("sheet1").Range("B3").Value & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End With

The problem is that my existing code shows an error if you have a file
name that already exists and you select Cancel or say No to saving over
the original file.

Can someone please let me have an example of how it should be.

Many thanks in anticipation


DonH
 
B

Bernie Deitrick

Don,

Put either of these (or both!) before your code:

On Error Resume Next
Application.DisplayAlerts = False

The first will get you out of the error situation that arises when the users presses Cancel or No to
the question, the second will allow Excel to automatically over-write any existing file.

HTH,
Bernie
MS Excel MVP
 
D

donh

Many thanks Bernie.


Bernie said:
Don,

Put either of these (or both!) before your code:

On Error Resume Next
Application.DisplayAlerts = False

The first will get you out of the error situation that arises when the users presses Cancel or No to
the question, the second will allow Excel to automatically over-write any existing file.

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top