In VB6.0, I have the following code. With this code Im able to get a valid count of all of the rows "populated" or as we call it a "record count", and pulling the sheet name from sheet 1.
When I upgraded this code to .NET, Im having issues with this.
I have all variables already declared (I omitted them for clarity).
Code:
Dim wkb As Excel.Workbook
Dim wks As Excel.Worksheet
Set wkb = Workbooks.Open(CommonDialog1.FileName) Open your file
xlsWorkSheet = wkb.Worksheets(1).Name Gives name of first worksheet.
Set wks = wkb.Worksheets.Item(1) Set up the worksheet
wks.UsedRange.Select Grab all used rows
XLSCount = Selection.Rows.Count Count the used rows
wkb.Close True, CommonDialog1.FileName Close the file when your done.
When I upgraded this code to .NET, Im having issues with this.
I have all variables already declared (I omitted them for clarity).