Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Main
- On Error Goto ErrorHandler ' Enables error handling
- Dim oActiveCell
- Dim oConv
- Dim replace As Object
- oActiveCell = ThisComponent.getCurrentSelection()
- oConv = ThisComponent.createInstance("com.sun.star.table.CellRangeAddressConversion")
- oConv.Address = oActiveCell.getRangeAddress
- Dim oSheet As Object : oSheet = ThisComponent.CurrentController.ActiveSheet
- replace = oSheet.createReplaceDescriptor
- replace.SearchRegularExpression = True
- replace.SearchString = "^."
- replace.ReplaceString = "&"
- Dim oRange As Object : oRange = oSheet.getCellRangebyName(oConv.UserInterfaceRepresentation)
- Dim oCell As Object
- Dim i As Integer, j As Integer
- For i = 0 To oRange.Rows.getCount() - 1
- For j = 0 To oRange.Columns.getCount() - 1
- oCell = oRange.getCellByPosition( j, i )
- oCell.replaceAll(replace)
- Next j
- Next i
- msgbox "Concluido"
- Exit Sub
- ErrorHandler:
- If Err = 423 then
- MsgBox "Essa Macro não funciona com seleções não adjacentes"
- Else
- MsgBox "Error code: " + Err + Chr$(13) + Error$
- End if
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement