M
Matthias Kwiedor
Hi!
I have a C# App which creates a Excel Sheet where Hyperlinks are
included.
If i create the file the first time or create a new Sheet it runs
without problems. But if i open the existing Sheet or add a new one and
try to append the new items to the existing items i get the hresult
error message. I reproduced the problem down to the call where i add the
hyperlinks to the sheet.
Here is the code-fragment:
Here i open the Excel App and open the Workbook and Worksheet!
Excel.ApplicationClass excelApp = new Excel.ApplicationClass();
excelApp.Visible = false;
Excel.Workbook newWorkbook newWorkbook = excelApp.Workbooks.Open
(ReportFile, 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);
Excel.Sheets sheets = newWorkbook.Worksheets;
Excel._Worksheet workSheet = (Excel._Worksheet)sheets.get_Item
(sheets.Count);
After that i run through the items i want to add. If i remove the
Hyperlink.Add call the items are added and everythink works fine.
intExcelRow is the Line where i want to add the new item.
Excel.Range itemRange = workSheet.get_Range("A" + intExcelRow.ToString
(), "AQ" + intExcelRow.ToString());
object[] objItem = new Object[1];
objItem[0] = excelItem;
itemRange.GetType().InvokeMember("Value",
System.Reflection.BindingFlags.SetProperty, null, itemRange, objItem);
workSheet.Hyperlinks.Add((Excel.Range)itemRange.Cells[1, 2],
"http://www.google.de/", Type.Missing, Type.Missing,
"http://www.google.de/");
I changed the Call to
workSheet.Hyperlinks.Add(workSheet.get_Range("B" + intExcelRow.ToString
(), Type.Missing), "http://www.google.de/", Type.Missing, Type.Missing,
"http://www.google.de/")
without any luck
Any help would be great
Matthias
I have a C# App which creates a Excel Sheet where Hyperlinks are
included.
If i create the file the first time or create a new Sheet it runs
without problems. But if i open the existing Sheet or add a new one and
try to append the new items to the existing items i get the hresult
error message. I reproduced the problem down to the call where i add the
hyperlinks to the sheet.
Here is the code-fragment:
Here i open the Excel App and open the Workbook and Worksheet!
Excel.ApplicationClass excelApp = new Excel.ApplicationClass();
excelApp.Visible = false;
Excel.Workbook newWorkbook newWorkbook = excelApp.Workbooks.Open
(ReportFile, 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);
Excel.Sheets sheets = newWorkbook.Worksheets;
Excel._Worksheet workSheet = (Excel._Worksheet)sheets.get_Item
(sheets.Count);
After that i run through the items i want to add. If i remove the
Hyperlink.Add call the items are added and everythink works fine.
intExcelRow is the Line where i want to add the new item.
Excel.Range itemRange = workSheet.get_Range("A" + intExcelRow.ToString
(), "AQ" + intExcelRow.ToString());
object[] objItem = new Object[1];
objItem[0] = excelItem;
itemRange.GetType().InvokeMember("Value",
System.Reflection.BindingFlags.SetProperty, null, itemRange, objItem);
workSheet.Hyperlinks.Add((Excel.Range)itemRange.Cells[1, 2],
"http://www.google.de/", Type.Missing, Type.Missing,
"http://www.google.de/");
I changed the Call to
workSheet.Hyperlinks.Add(workSheet.get_Range("B" + intExcelRow.ToString
(), Type.Missing), "http://www.google.de/", Type.Missing, Type.Missing,
"http://www.google.de/")
without any luck
Any help would be great
Matthias