06-21-2010, 01:34 PM
How to replace existing excel file while using Save as Method ?
For ex:- In the following code if Newfile.xls already exist ,it gives me alert "Do u want to replace it?" .
For ex:- In the following code if Newfile.xls already exist ,it gives me alert "Do u want to replace it?" .
Code:
TestSuitFileLocation="H:"
TestSuitFileName="H:\Book.xls"
TestSuitFileNewName="NewFile.xls"
Set excelApp = CreateObject("Excel.Application")
excelApp.Visible = true
Set TestSuiteExcelFile = excelApp.Workbooks.Open (TestSuitFileName)
TestSuiteExcelFile.SaveAs TestSuitFileLocation& "\"&TestSuitFileNewName
TestSuiteExcelFile.close
excelApp.quit
Set excelApp = Nothing