M
Mircea Pleteriu
Hi,
I am experiencing a problem with Excel which I cannot figure out.
Here it it.
I develop a C# plug in for Excel with VS for Office.
I want to copy a range from an external Excel document into the current
document at the position of the active cell.
Here is my code:
****************************
// Open the source workbook from where to copy the typical range
Excel.Application srcApp = new Excel.ApplicationClass();
Excel.Workbook srcWorkbook = srcApp.Workbooks.Open(fileName, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing);
// Get range to copy
Excel.Name name = srcApp.Names.Item("MyRangeName", Type.Missing,
Type.Missing);
Excel.Range range = name.RefersToRange;
// Copy range to current document at the position of the active cell
range.Copy(ThisApplication.ActiveCell);
**************************
The problem is that the Copy method fails with the error message: "Copy
method of Range class failed."
I am experiencing a problem with Excel which I cannot figure out.
Here it it.
I develop a C# plug in for Excel with VS for Office.
I want to copy a range from an external Excel document into the current
document at the position of the active cell.
Here is my code:
****************************
// Open the source workbook from where to copy the typical range
Excel.Application srcApp = new Excel.ApplicationClass();
Excel.Workbook srcWorkbook = srcApp.Workbooks.Open(fileName, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing);
// Get range to copy
Excel.Name name = srcApp.Names.Item("MyRangeName", Type.Missing,
Type.Missing);
Excel.Range range = name.RefersToRange;
// Copy range to current document at the position of the active cell
range.Copy(ThisApplication.ActiveCell);
**************************
The problem is that the Copy method fails with the error message: "Copy
method of Range class failed."