ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving Excel as latest version (https://www.excelbanter.com/excel-programming/365670-saving-excel-latest-version.html)

Nirmal Singh[_2_]

Saving Excel as latest version
 

I have an Excel 3.0 spreadsheet. I am using the following COM code to open the spreadsheet,
make a copy of the worksheet, rename both worksheets and save in my version of Excel
(Excel 2002).

xlApp.Workbooks.Open(txtSpreadsheet.Text, EmptyParam, True, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, user);
xlSheet.ConnectTo(xlApp.Worksheets[1] as _Worksheet);
xlSheet.Copy(xlApp.Worksheets.Item[1]);
xlSheet.Name:='Sent';

xlSheet.ConnectTo(xlApp.Worksheets.Item[1] as _Worksheet);
xlSheet.Name:='Generic';

xlApp.DisplayAlerts[user]:=False;
xlApp.DefaultSaveFormat:=xlWorkbookNormal;
xlApp.ActiveWorkbook.Close(True,'NewName.xls', EmptyParam,user);
xlApp.DisplayAlerts[user]:=True;

The problem that I am having is that the active worksheet ('Sent') is being
renamed to 'NewName' before the save. I presume this is because it was originally
an Excel 3.0 spreadsheet. How can I get around this behaviour?

Nirmal


All times are GMT +1. The time now is 04:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com