Ask Your Question

(Solved) Modify character properties within Writer selection using Basic macro [closed]

asked 2013-04-01 21:32:14 +0200

Pansmanser gravatar image

updated 2015-10-29 16:15:57 +0200

Alex Kemp gravatar image

In a Writer Basic macro, I am trying to increase font size of every character within the selection. This subroutine works well, but operates over the whole document, not just the selection. Can I limit the range to the selected text?

Sub FontUp 'Increase size of each character in selection by 1.

Dim oSel as Object, oTC as Object, oParEnum as Object, oPar as Object,

Dim oSecEnum as Object, oSec as Object, CharHeight As Long

oSel = ThisComponent.CurrentSelection.getByIndex(0)    'get the current selection
oTC = ThisComponent.Text.createTextCursorByRange(oSel) ' and span it with a cursor

rem Scan the cursor range for chunks of given text size.

oParEnum = oTC.Text.createEnumeration()
  Do While oParEnum.hasMoreElements()
    oPar = oParEnum.nextElement()

    If oPar.supportsService("") Then
      oSecEnum = oPar.createEnumeration()
      Do While oSecEnum.hasMoreElements()
        oSec = oSecEnum.nextElement()
        If oSec.TextPortionType = "Text" Then
          CharHeight = oSec.CharHeight
          oSec.CharHeight = CharHeight - 1
        End If
    End If


End Sub

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-29 16:16:07.540036

1 Answer

Sort by » oldest newest most voted

answered 2013-04-05 16:19:05 +0200

Pansmanser gravatar image

updated 2013-04-05 20:31:40 +0200

manj_k gravatar image

I now have a solution to this problem provided on the OOo Forum by Bernard and B Marcelly.

Thanks to both!

edit flag offensive delete link more


Bernard = B Marcelly ;)

manj_k gravatar imagemanj_k ( 2013-04-05 20:37:00 +0200 )edit

Question Tools

1 follower


Asked: 2013-04-01 21:32:14 +0200

Seen: 1,159 times

Last updated: Apr 08 '13