Guest User

Untitled

a guest
Oct 17th, 2018
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. Sub Main
  2.  
  3. oSels = ThisComponent.CurrentSelection
  4.  
  5. myRanges = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
  6.  
  7. oView = ThisComponent.getCurrentController()
  8. oSheet = oView.getActiveSheet()
  9.  
  10. If oSels.getImplementationName() = "ScCellRangesObj" Then
  11.  
  12. For selIndex = 0 to oSels.getCount() - 1
  13. oSel = oSels.getByIndex(selIndex)
  14. parts = Split(oSel.AbsoluteName,".")
  15. part = parts(UBound(parts))
  16. part = Replace(part,"$","")
  17.  
  18. rg = oSheet.getCellRangeByName(part)
  19. myRanges.addRangeAddress(rg.getRangeAddress(), False)
  20.  
  21. MsgBox part
  22.  
  23. Next selIndex
  24.  
  25. Else
  26.  
  27. Dim oConv as Object
  28.  
  29. oConv = ThisComponent.createInstance("com.sun.star.table.CellRangeAddressConversion")
  30.  
  31. oConv.Address = oSels.getRangeAddress
  32.  
  33. MsgBox oConv.UserInterfaceRepresentation
  34.  
  35. rg = oSheet.getCellRangeByName(oConv.UserInterfaceRepresentation)
  36.  
  37. myRanges.addRangeAddress(rg.getRangeAddress(), False)
  38.  
  39. End If
  40.  
  41. REM abaixo aplicaremos a acao desejada ao(s) intervalo(s) selecionado(s)
  42.  
  43. for each rg in myRanges()
  44.  
  45. For i = 0 To rg.Rows.getCount() - 1
  46.  
  47. For j = 0 To rg.Columns.getCount() - 1
  48.  
  49. oCell = rg.getCellByPosition( j, i )
  50.  
  51. oCell.String = "oi"
  52.  
  53. Next j
  54.  
  55. Next i
  56.  
  57. next
  58.  
  59. End Sub
Advertisement
Add Comment
Please, Sign In to add comment