M
MadmartiganL
I'm using Windows XP SP2 and MS Office 2007. The following code where I try
to access any cell in any workbook returns "Exception from HRESULT:
0x800A03EC". I'm dead out of ideas and searching the internet wasn't any
help. Hope you guys can help me out here!
Imports Microsoft.Office.Interop
Public Class ExcelLink
Private workbook as Excel.Workbook
Private worksheets() as String
Private app as Excel.Application
Public Sub OpenFile(Byval fileName as String)
app = New Excel.Application
workbook = app.Workbooks.Open(fileName)
End Sub
Public function GetColumns(ByVal sheet As String)
Dim columns() As String
Dim worksheet As New Excel.Worksheet
Dim i As Integer
For i = 1 To workbook.Worksheets.Count()
If workbook.Worksheets.Item(i).Name.Equals(sheet) Then
worksheet = workbook.Worksheets.Item(i)
End If
Next
i = 1
While (worksheet.Cells(1, i).ToString <> "") 'this is where the error is
at, using "A1" etc to select the sell doesn't work either, using Ranges gives
the same problem.
ReDim Preserve columns(i)
columns(i - 1) = worksheet.Cells(1, i)
i = i + 1
End While
End Function
End Class
to access any cell in any workbook returns "Exception from HRESULT:
0x800A03EC". I'm dead out of ideas and searching the internet wasn't any
help. Hope you guys can help me out here!
Imports Microsoft.Office.Interop
Public Class ExcelLink
Private workbook as Excel.Workbook
Private worksheets() as String
Private app as Excel.Application
Public Sub OpenFile(Byval fileName as String)
app = New Excel.Application
workbook = app.Workbooks.Open(fileName)
End Sub
Public function GetColumns(ByVal sheet As String)
Dim columns() As String
Dim worksheet As New Excel.Worksheet
Dim i As Integer
For i = 1 To workbook.Worksheets.Count()
If workbook.Worksheets.Item(i).Name.Equals(sheet) Then
worksheet = workbook.Worksheets.Item(i)
End If
Next
i = 1
While (worksheet.Cells(1, i).ToString <> "") 'this is where the error is
at, using "A1" etc to select the sell doesn't work either, using Ranges gives
the same problem.
ReDim Preserve columns(i)
columns(i - 1) = worksheet.Cells(1, i)
i = i + 1
End While
End Function
End Class