Wednesday 15 June 2011

vba - access 2010 getting max row in excel 2010 -


I have a problem reaching Excel 2010 through MS Access 2010. Accessed 2010, I want to get the maximum number of my excel information. Here is my code:

 Excel.Application as the slow XL - dim XLBook in the form of Excel. Workbook - Dim XLSheet as Axle Worksheet 
Thum Up Time I Set Integrate - MySheetPath = "C: \ user \ myaccount \ Desktop \ LRLV \ mydata.xlsx"
XL = Create Object ("Excel Application") - XLbook = Set up the XL Visible = True
XlBook.Windows (1) .Visible = True Set
XlSheet = XlBook.Worksheets (1)
with XlSheet
lastRow = .Cells.Find (What: = "*", after: = [A1], Searchorder: = XLBRO, Search Direction: = XL Preverses). Android with ROW
When I have a Excel Ola otherwise everything is fine. But when I have 1 or more superior that the "last row" of the VeriBella has been opened, then always give me a "type mismatch" error. Now I should know how to fix it. Thanks a lot before.

Your problem is inappropriate reference to A1 I also do not know that when you already have an app reference So why do you use GetObject

  Dim Xl as Excel As the Applet Dim XlBook Excel As Workbook Dim XlSheet Excel As long as the worksheet staining, I set the integer MySheetPath = "C: \ users \ myaccount \ Desktop \ LRLV \ mydata.xlsx" Xl = CreateObject ("Excel.Application") Xl.Visible = True Set XlBook = XL.Workbooks.Open (MySheetPath) XlBook Windows (1) .Visible = True Set XlSheet = XlBook.Worksheets (1) with XLSheet lastRow = .Cells.Find (what: = "*", after: = range. ("A1"), SearchOrder: = xlByRows, SearchDirection: = Xl preverses) .Ro and End    

No comments:

Post a Comment