Hi All,
I am just starting to work with excel files through x . As you may guess I know very little.
I have a template already made in Excel where I want to fill it with the data from the a selected production. this template is called routecard (RK).
since I don't want to modify the existing template I prefer to Open a copy of the template from X and modify from there.
Since I dont know exacly how to do that I am starting by creating a new file (RK_new), and copy each sheet from the template RK excel (RK)
here is what I'got so far. The problem is in the two last lines where I want to add a new sheet infolog shows: "COM Object, method add called with invalid parameters"
you help is greatly appreciated , I am quite sure there should be an easier solution just by somehow clone the workbooks
//******** template WorkBook SysExcelApplication appRK; SysExcelWorkbooks wbsRK; SysExcelWorkbook wbRK; SysExcelWorksheets wssRK; SysExcelWorksheet wsRK; SysExcelCells cellsRK; COMVariantType typeRK; FileName filename; //******** New WorkBook SysExcelApplication appRK_new; SysExcelWorkbooks wbsRK_new; SysExcelWorkbook wbRK_new; SysExcelWorksheets wssRK_new; SysExcelWorksheet wsRK_new; SysExcelCells cellsRK_new; COMVariantType typeRK_new; int rowRK_new; ItemId itemidRK_new; //******* Open the Original RK Template appRK = SysExcelApplication::construct(); wbsRK = appRK.workbooks(); filename = "W:\\Rutekort\\Poland\\RK_PL.xlsm"; try { wbsRK.open(filename,0,true); appRK.visible(true); } catch (Exception::Error) { throw error("File cannot be opened."); } wbRK = wbsRK.item(1); wssRK = wbRK.worksheets(); //******* Open New Excel for RK appRK_new = SysExcelApplication::construct(); wbsRK_new = appRK_new.workbooks(); wbRK_new = wbsRK_new.add(); // Creates new excel File wssRK_new = wbRK_new.worksheets(); //point to the its worksheets appRK_new.visible(true); //***** copying the first ws into the new workbook RK_new * ERROR wsRK_new = wssRK.itemFromNum(1); wssRK_new.add(wsRK_new);