I am trying to edit an Excel file from MS Access without using Excel as a reference. I found an answer in this question that helps with this problem. Instead of using references to Excel, I use Objects. This seems to work for the most part, but I don't get all the functions I need from Excel in order to count the rows on a table. A snippet of my code is as follows:
Dim xlBook As Object
Dim xlApp As Object
Dim xlSht As Object
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Some\Location.xlsx")
Set xlSht = xlBook.Sheets("SomeSheet")
tableRows = xlSht.Cells(xlSht.Rows.Count, 2).End(xlUp).Row
I get an error on the tableRows = xlSht...
line which reads:
Run-time error '1004':
Application-defined or object-defined error
I've tried numerous different ways of fixing this problem, such as rewriting the line, changing the sheetnames. I can't seem to find any documentation on this scenario. I'd appreciate any help.