Save

  • Thread starter Thread starter Edward
  • Start date Start date
E

Edward

Hi Everybody,
I'm programming Excel in Outlook and export some data from Outlook to Excel,
I want to save newly added data in Excel and I use the following code
appExcel.Activeworkbook.Save
but I get the following message
A file named "xyz.xls" already exists in this clocation . Do you wnat to
replace it?
how can I avoid this message?

by the way I use the following code as well
Set appExcel=Createobject("Excel.application")
appExcel.workbooks.open(" filepath ")
 
There are (at least) two ways to do this:

On Error Resume Next
Kill "xyz.xls"
appExcel.ActiveWorkbook.Save

' Or

Application.DisplayAlerts = False
appExcel.ActiveWorkbook.Save
Application.DisplayAlerts = True

If the file already exists, you might want to consider sending to the
Recycle Bin rather than killing it. See
www.cpearson.com/Excel/Recycle.aspx for info about sending a file to
the recycle bin.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Back
Top