Excel SaveAs

Deepthiv

Active member
Joined
Oct 3, 2005
Messages
39
Programming Experience
3-5
oExcel.Workbooks("C:\report\res.xls").SaveAs("C:\Test1.xls")
oExcel.Workbooks(("C:\Test1.xls")).Save()
oExcel.Workbooks(("C:\Test1.xls")).Close()

or

oExcel.Workbooks(("C:\report\res.xls")).Close(SaveChanges:=
True, "C:\Test1.xls")

i tired to use above 2 statements but unfortunately SaveAs to another file is not working

I need to save "C:\report\res.xls" file As "C:\Test1.xls"

Can some one help me in this reg..

Thanks,
Deepthi
 
Provided oExcel is is the application level obj then the following will work...

VB.NET:
oExcel.ActiveWorkbook.SaveAs("C:\Test1.xls", _
 FileFormat:=Excel.XlFileFormat.xlXMLSpreadsheet)

This of course assumes that the file you wish to save with this name is the active one. This will not overwrite the version you opened. Unless you close "Test1.xls" and reopen "report\res.xls" then any additional changes will only happen to the "Test1.xls" file.

Last but not lease the "FileFormat" portion is optional.

A Good resource for Excel work can be found here...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2003_ta/html/excelobj.asp
 
Back
Top