Hi, I am working on a windows service, which will open a Excel file in In-Visible mode. Then it will add some data to some sheets and perform calculations using formulas in excel and get the result. This all working fine, but i am facing a problem regarding Copy & Paste formula in Hidden and Protected sheet and protected work book. Here is my code so far: //Copy the first cell which has formula Excel.
Range copyRange = sheet.get_Range(FIRST_CELL, FIRST_CELL); sheet.Unprotect(
"dsfdfdsfds"); copyRange.Select(); copyRange.Copy(
Type.Missing); \\EXCEPTION HERE
//Find last cell in this sheet
int lastRow = ((Excel.Range)sheet.Cells[7, 3]).get_End(Excel.XlDirection.xlDown).Row;
//Paste formula into all the "A" column cells Excel.
Range pasteRange = sheet.get_Range(START_AT_CELL, "A" + lastRow.ToString()); pasteRange.PasteSpecial(Excel.
XlPasteType.xlPasteFormulas, Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, false, false); In the above code, i getting exception at copyRange.Copy(Type.Missing); Exception: Select Method of range class failed. Please help.
AnswersAll Replies |
|