hello,
sorry for my bad english.
i am trying to write to an existing excel file (.xls format).
this existing excel file has a macro in it.
the problem is when i try to save it (using Workbook.Save(targetfile)), it can be saved successfully but all the macros are gone.
here are my snippet codes :
Workbook ExistingWorkbook = new Infragistics.Documents.Excel.Workbook(WorkbookFormat.Excel2007MacroEnabled); ExistingWorkbook = Workbook.Load(workbookPath2); //workbookPath2 is a .xls file foreach (Worksheet sheet in ExistingWorkbook.Worksheets) { if (sheet.Name.Equals(currentSheet2)) { for (int i = 1; i <= 204; i++) { if (i <= 55) { int x = i + 17; WorksheetRow row = sheet.Rows[x]; row.Cells[4].Value = excel_temp[i.ToString()].ToString(); }
....
ExistingWorkbook.Save(workbookPath2);
Any replies are really appreciated.
Thank you.
Which version are you using? There is support to round-trip VBA code, but currently, forms which use them are not preserved.