[Solved] Macro to obtain row column like Ctrl-End does
[Solved] Macro to obtain row column like Ctrl-End does
I need a basicmacro in Calc that will get the row and column of the last filled cell like ctrl+end does, but without moving the cursor. Any ideas?
Last edited by norisezp on Sat Apr 16, 2016 5:13 pm, edited 1 time in total.
OpenOffice 2.4 on Ubuntu 9.04
Re: Macro to obtain row column like Ctrl-End does
Try something like this
Code: Select all
oSheets = ThisComponent.getSheets()
oSheet = oSheets.getByName("Sheet1")
oCurs = oSheet.createCursor()
oCurs.gotoEndOfUsedArea(False)
print oCurs.AbsoluteName
print " Column Index = " & oCurs.RangeAddress.StartColumn & " Row Index = " & OCurs.RangeAddress.StartRow
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Macro to obtain row column like Ctrl-End does
Thank you. Question: If code gets serially reused, is it necessary to delete the oCurs object on each trip through, to avoid filling up the heap and/or stack?
OpenOffice 2.4 on Ubuntu 9.04
Re: Macro to obtain row column like Ctrl-End does
Once you create the cursor with oCurs = oSheet.createCursor(), you can reuse that object as much as you want. You don't need to create a new cursor for each use. For example, if you have a loop in your code, put the createCursor() statement outside of the loop and the commands to move the cursor inside of the loop. Is that the sort of use you are asking about?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Macro to obtain row column like Ctrl-End does
It's actually in a function, but I can make it global easily enough. Thank you very much. I'll punch he Answered key.
OpenOffice 2.4 on Ubuntu 9.04