Page 1 of 1

Select last cell used in Excel

Posted: Fri Oct 17, 2014 1:45 pm
by mau_rizio
Hi all, this is my first project with PureBasic after some tests with the demo version, and i would like to share a little piece of code to use with COMate and Excel files.

I'm converting an Access application that import data from an Excel spreadsheet, where i use

Code: Select all

excelApp.ActiveCell.SpecialCells(xlLastCell).Select to select the last cell used 
excelApp.ActiveCell.Column
excelApp.ActiveCell.Row to get the column and the row of the cell.
So in PB i use:

Code: Select all

    ExcelObject\Invoke("ActiveCell\SpecialCells(11)\Select")
    Row = ExcelObject\GetIntegerProperty("ActiveCell\Row" ) 
    Col = ExcelObject\GetIntegerProperty("ActiveCell\Column" ) 
After hours of testing i've found out that xlLastCell in not recognized, so i've to use it's numeric value.

Hope this helps :)
mau

PS: A big thank you to srod for COMate and to leodh for a very usefull example.