Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2007

Tip: Looking for answers? Try searching our database.

VBA Error when Saving an existing file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
donh - 18 Jan 2007 09:27 GMT
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
Bernie Deitrick - 18 Jan 2007 14:32 GMT
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

> Hi Folks,
>
[quoted text clipped - 17 lines]
>
> DonH
donh - 19 Jan 2007 09:42 GMT
Many thanks Bernie.

> Don,
>
[quoted text clipped - 31 lines]
> >
> > DonH
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.