F
frankvfox
I'm trying to insert an image into an Excel cell. Please see the following
code. Does
anybody have a way to fix this "COMException"? I thought setting the new
reference in Visual Studio
took care of "wrapping" COM objects for use with .Net?
I can't even get the workbook object established let alone see if the rest
of this works!
Imports Microsoft.Office.Interop.Excel
Private Sub Spreadsheet()
Dim i As System.Drawing.Image
Dim xl As New Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim range As Microsoft.Office.Interop.Excel.Range
xl.Workbooks.Add(wb) <--------------------------------------- Error
Location
wb.Sheets.Add(ws)
range = ws.Range(5, 5)
i =
System.Drawing.Image.FromFile("C:\inetpub\wwwroot\capitalprojects\Images\GSImgtmpED6.png")
range.Select()
ws.PasteSpecial(i)
ws.SaveAs("C:\test.xls")
xl.Quit()
i.Dispose()
End Sub
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in Scratch.exe
Additional information: Exception from HRESULT: 0x800A03EC.
Any help greatly appreciated.
Frank Fox
Hendersonville, Tennessee
code. Does
anybody have a way to fix this "COMException"? I thought setting the new
reference in Visual Studio
took care of "wrapping" COM objects for use with .Net?
I can't even get the workbook object established let alone see if the rest
of this works!
Imports Microsoft.Office.Interop.Excel
Private Sub Spreadsheet()
Dim i As System.Drawing.Image
Dim xl As New Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim range As Microsoft.Office.Interop.Excel.Range
xl.Workbooks.Add(wb) <--------------------------------------- Error
Location
wb.Sheets.Add(ws)
range = ws.Range(5, 5)
i =
System.Drawing.Image.FromFile("C:\inetpub\wwwroot\capitalprojects\Images\GSImgtmpED6.png")
range.Select()
ws.PasteSpecial(i)
ws.SaveAs("C:\test.xls")
xl.Quit()
i.Dispose()
End Sub
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in Scratch.exe
Additional information: Exception from HRESULT: 0x800A03EC.
Any help greatly appreciated.
Frank Fox
Hendersonville, Tennessee