# Run full document Macro

Hello, everyone! I need to run a macro to the full document.

The macro its very simple.

1) set the cursor at the begining of the page 2) press shift, then press the END key, this selects the full line text. 3) change the color of the selected tex 4) set the text size to 24

5) press the HOME key, this sends the cursor to the begining of the text line 6) press the DOWN ARROW ket twice, this skips one line of text

The avobe steps are the whole micro. Now I need to know how to run it the full document.

Note: I try to edit the micro,I just copy the steps and paste them below the original code and it WORKS very well.

But to edit all the steps takes alot of work.

I hope that there is a way to get the micro into a ' for loop ' or something.

Thanks in advance for the help.

If there any source to learn to crate scripts for LibreOffice please let me know. Thanks again. lilcobra

edit retag close merge delete

Sort by » oldest newest most voted

Hello @lilcobra, if i understood your question correctly, then the following macro would format your entire document based on your specifications above:

Sub FormatPage_lilcobra()
Dim oTextCursor as Object, oText As Object, b As Boolean
oText = ThisComponent.getText()
oTextCursor = oText.createTextCursor()
oTextCursor.gotoStart( False )
Do
b = oTextCursor.gotoEndOfParagraph( True )
oTextCursor.CharHeight = 24
oTextCursor.CharColor = 16222213    REM change text color.
b = oTextCursor.gotoNextParagraph( False )  REM skip 1 line.
b = oTextCursor.gotoNextParagraph( False )
Loop While b
End Sub


EDIT: per line

Sub FormatPage_lilcobra2()
REM Per line ( not per paragraph ).
Dim oViewCursor as Object, b As Boolean
oViewCursor = ThisComponent.getCurrentController.getViewCursor()
oViewCursor.gotoStart( False )
Do
b = oViewCursor.goDown( 1, True )
oViewCursor.CharHeight = 24
oViewCursor.CharColor = 16222213    REM change text color.
b = oViewCursor.goDown( 1, False )
Loop While b
End Sub

more

Thank you, Librebel.

I will give it a try and let you know.

thank you for the help.

But the way this is the code that was created by recording the macro... then I was just copy and editing the args02 numbers and then paste at the end.... over and over again... it works... but looks like a silly code.

code rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:EndOfLineSel", "", 0, Array())

rem ---------------------------------------------------------------------- dim args68(0) as new com.sun.star.beans.PropertyValue args68(0).Name = "FontColor" args68(0).Value = 16222213

dispatcher.executeDispatch(document, ".uno:FontColor", "", 0, args68())

rem ---------------------------------------------------------------------- dim args69(2) as new com.sun.star.beans.PropertyValue args69(0).Name = "FontHeight.Height" args69(0).Value = 24 args69(1).Name = "FontHeight.Prop" args69(1).Value = 100 args69(2).Name = "FontHeight.Diff" args69(2).Value = 0

dispatcher.executeDispatch(document, ".uno:FontHeight", "", 0, args69())

rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:GoToStartOfLine", "", 0, Array())

rem ---------------------------------------------------------------------- dim args70(1) as new com.sun.star.beans.PropertyValue args70(0).Name = "Count" args70(0).Value = 1 args70(1).Name = "Select" args70(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args70())

rem ---------------------------------------------------------------------- dim args71(1) as new com.sun.star.beans.PropertyValue args71(0).Name = "Count" args71(0).Value = 1 args71(1).Name = "Select" args71(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args71())

more

You're welcome @lilcobra, i edited the example to adjust the textcolor to 16222213.

( 2017-06-25 02:47:53 +0200 )edit

Hello librebel, i try the macro it runs Ok and changes the text color and the text hight, BUt it Not skips the text line. I try to edit the macro to make it skip one line but dint work. I hope you have the answer. thank you.

( 2017-06-25 19:53:22 +0200 )edit

I posted a second example in my answer, please see if that works.

( 2017-06-25 23:34:53 +0200 )edit