Select last cell used in Excel

Just starting out? Need help? Post your questions and find answers here.
mau_rizio
New User
New User
Posts: 3
Joined: Tue Aug 26, 2014 4:10 pm
Location: Florence -Italy

Select last cell used in Excel

Post 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.