RIAS
asked on
Count number of excel rows +excel 2007 onwards+vb.net 2005
Hi,
I had a previous code to count number of rows in excel 2003 version sheet.But it errors in 2007.Any suggestions
Public Function GetColumnRowCount(ByVal col As Integer, ByVal xlWorksheet As Object, ByVal xlApp As Object) As Integer
Try
Return xlWorksheet.Cells(xlWorksh eet.Rows.C ount, col).End(-4162).Row
Catch ex As Exception
AddMessage(ex.ToString)
End Try
End Function
Error:
System.Runtime.InteropServ ices.COMEx ception (0x800A03EC): Exception from HRESULT: 0x800A03EC
I had a previous code to count number of rows in excel 2003 version sheet.But it errors in 2007.Any suggestions
Public Function GetColumnRowCount(ByVal col As Integer, ByVal xlWorksheet As Object, ByVal xlApp As Object) As Integer
Try
Return xlWorksheet.Cells(xlWorksh
Catch ex As Exception
AddMessage(ex.ToString)
End Try
End Function
Error:
System.Runtime.InteropServ
ASKER
Cheers I changed that and it works great.
But any suggestion on why it fails on
Dim oRange As Excel.Range
oRange(1, 1).Value
Excel.Range is the interop excel reference.
Same error
System.Runtime.InteropServ ices.COMEx ception (0x800A03EC): Exception from HRESULT: 0x800A03EC
But any suggestion on why it fails on
Dim oRange As Excel.Range
oRange(1, 1).Value
Excel.Range is the interop excel reference.
Same error
System.Runtime.InteropServ
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers mate !!!Works like charm
Return xlWorksheet.UsedRange.Rows