I was just wondering: createCursor() creates a cursor containing the whole sheet, which could be slow when you have a big sheet.
Maybe this is a way to create the cursor with better performance.

Just an idea, Steffen

Andrew Douglas Pitonyak wrote:
Nice tip... I will change this in my document...

I have no idea why this is written as it is, but many of the snippets were created years ago with OOo 1.x, so, the issue may be that the author of that particular macro (probably me) was not properly efficient, or, that OOo did not support the methodology. In this case, I suspect the first.

On 08/30/2009 08:54 AM, Johnny Rosenberg wrote:
At page 142 in the macro manual by A. Pitonyak, there is a section
about how to do it, here's a function that returns the last column of
the used area:

Function getLastUsedColumn(oSheet as Object) as Integer
   Dim oCell As Object
   Dim oCursor As Object
   Dim aAddress As Variant
   oCell = oSheet.GetCellbyPosition( 0, 0 )
   oCursor = oSheet.createCursorByRange(oCell)
   oCursor.GotoEndOfUsedArea(True)
   aAddress = oCursor.RangeAddress
   GetLastUsedColumn = aAddress.EndColumn
End Function

I am wondering about the oCell thing. Why is that necessary? I tried
the following and it seems to work:

Function getLastUsedColumn(oSheet as Object) as Integer
   Dim oCursor As Object
   Dim aAddress As Variant
   oCursor = oSheet.createCursor
   oCursor.GotoEndOfUsedArea(True)
   aAddress = oCursor.RangeAddress
   GetLastUsedColumn = aAddress.EndColumn
End Function

Or even shorter, and still works and just as easy to follow (in my opinion):

Function getLastUsedColumn(oSheet as Object) as Integer
   Dim oCursor As Object
   oCursor = oSheet.createCursor
   oCursor.GotoEndOfUsedArea(True)
   GetLastUsedColumn = oCursor.RangeAddress.EndColumn
End Function

Johnny Rosenberg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to