' Alexandr Kostin, textsize, 20062016, v14.1 2016.03, koostiin@gmail.com
Public Sub TextSize()
Dim frst As Long, scnd As Long, fs As Long, i As Long, v As Long, bi As Long
Dim cnt As Long, SpecChar As String, WordCnt As Long, Words As Long
'Dim Cursor As Object, Proceed As Boolean 'OO Writer
'Cursor = StarDesktop.CurrentComponent.Text.createTextCursorByRange(ThisComponent.CurrentController.getViewCursor()) 'OO Writer
frst = 10
scnd = 30
i = 1
v = 1
WordCnt = 0
Words = 200
SpecChar = ".,:;()<>!?+-*/=@#$%^&~[]{}|\ " + Chr(34) + Chr(13) + Chr(171) + Chr(187) + Chr(151) 'MS Word
Randomize 'MS Word
'Randomize (Right(Time(), 2)) 'OO Writer
'Cursor.gotoStartOfWord (False) 'OO Writer
While (Selection.End < ActiveDocument.Paragraphs.Last.Range.End - 1) 'MS Word
'Do 'OO Writer
    Selection.MoveRight wdWord, 1, wdExtend 'MS Word
    'Cursor.gotoEndOfWord (True) 'OO Writer
    If InStr(SpecChar, Left(Selection.Text, 1)) = 0 Then 'MS Word
        WordCnt = WordCnt + 1
        If Selection.Characters.Last = " " Then 'MS Word
            cnt = Selection.Characters.Count - 1 'MS Word
        Else 'MS Word
            cnt = Selection.Characters.Count 'MS Word
        End If 'MS Word
        'cnt = Len(Cursor.String) 'OO Writer
        If v = 1 Then
            If fs < frst Then fs = scnd
        Else
            fs = Int(((scnd - frst + 1) * Rnd) + frst)
        End If
        Selection.Font.Size = fs 'MS Word
        'Cursor.CharHeight = fs 'OO Writer
        bi = Int(3 * Rnd + 1)
        Selection.Font.Bold = False 'MS Word
        Selection.Font.Italic = False 'MS Word
        'Cursor.CharWeight = com.sun.star.awt.FontWeight.NORMAL 'OO Writer
        If bi = 2 Then Selection.Font.Bold = True 'MS Word
        If bi = 3 And fs >= 14 Then Selection.Font.Italic = True 'MS Word
        'If bi = 2 Then Cursor.CharWeight = com.sun.star.awt.FontWeight.BOLD 'OO Writer
        'If bi = 3 And fs >= 14 Then Cursor.CharPosture = com.sun.star.awt.FontSlant.ITALIC 'OO Writer
        If cnt < 3 Then
            Selection.Font.Size = 14 'MS Word
            'Cursor.CharHeight = 14 'OO Writer
        Else
            If v = 1 Then
                If i <= 2 Then
                    i = i + 1
                Else
                    fs = fs - 2
                    i = 1
                End If
            End If
        End If
    Else 'MS Word
        Selection.Font.Size = 14 'MS Word
    End If 'MS Word
    If (WordCnt / Words) - Int(WordCnt / Words) = 0 Then
        v = 0 - v
        fs = scnd
    End If
    Selection.Move wdCharacter 'MS Word
    'Proceed = Cursor.gotoNextWord(False) 'OO Writer
Wend 'MS Word
'Loop While Proceed 'OO Writer
'MsgBox "Ok" 'OO Writer
End Sub
