Posted By

thefamousnomo on 01/17/13


Tagged

basic open macro calc office openoffice


Versions (?)

insert page breaks in oocalc spreadsheet


 / Published in: Other
 

page break inserted when first letter of first cell in row changes

  1. Sub Main
  2.  
  3. Dim oSheets : Dim oSheet : Dim oUsedRange : Dim oCursor : Dim lastRow : Dim I As Integer : Dim oCell : Dim lastVal As String
  4.  
  5. oSheets = ThisComponent
  6. oSheet = oSheets.Sheets(0)
  7.  
  8. oUsedRange = oSheet.getCellRangeByPosition(0,0,0,0)
  9. oCursor = oSheet.createCursorByRange(oUsedRange)
  10. oCursor.GotoEndOfUsedArea(false)
  11. lastRow = oCursor.RangeAddress.EndRow
  12.  
  13. for I = 0 to lastRow
  14. oCell = oSheet.getCellByPosition(0, I)
  15. if Left(oCell.String, 1) <> lastVal Then
  16. 'MsgBox Left(oCell.String, 1)
  17. oCell.Rows.IsStartOfNewPage = True
  18. endif
  19. lastVal = Left(oCell.String, 1)
  20. next I
  21.  
  22. End Sub

Report this snippet  

You need to login to post a comment.