Hello.
I almost always do the same kind of lines : same color, same thickness and same arrow.
I want to create a button which calls a macro that applies these 3 modifications to the line selected.
When I record the steps to do it, it record a macro almost empty, which does nothing.
What should I write in that macro ?
Why don’t you just use styles for that? You don’t need any macros.
Because no style seem to apply to a line.
They all apply to text.
When I select any text, it becomes overlined in the styles list.
But when I select a line, nothing is selected.
The simplest way is to add your arrow to the Gallery:
- Draw the arrow with your preferred attributes
- Open the Gallery pane in the Sidebar and select Arrows
- Click and hold on your arrow for a couple of seconds until the cursor changes to an arrow with a square box then drag the arrow into the opened Gallery pane
To use in any LibreOffice program, simply drag the arrow from the Gallery pane into your document and release when positioned correctly. Alter length and angle as desired.
.
Or you could use AutoText
- Open a new document and add an arrow with your wanted attributes. Position it relative to the paragraph mark as you think it should be. It can be changed after insertion but better to get it close to the paragraph mark to avoid surprises down the track.
- Press Ctrl+A (Edit > Select All)
- Click Tools > AutoText
- In the dialogue that opens
- Give your arrow a name, e.g. Arrow Red. Note the Shortcut is AR
- Select My AutoText as the category
- Click the drop down arrow on the button labelled AutoText
- Click New. You can Close the dialogue box
To test, open a new Writer document, type ar then press F3 (on some computers it might be Fn+F3). A new arrow should be positioned on the page the same as original. You can, of course, drag it anywhere on the page. Alter length and angle as desired.

.
Clone Formatting
- Create or format an arrow with the attributes that you want.
- Select the arrow and the double-click the paintbrush icon with tooltip Clone formatting*
- Click the bucket cursor on each arrow that you want to be formatted the same (not length or angle)
.
Paragraph Style Ligne horizontale
This is for lines going across the page or column and cannot take an arrow because it is an empty paragraph with just a lower border. To apply make a return (press Enter) and then double-click the Ligne horizontale paragraph style to apply it.
You can Modify the style to suit or create a new style by right clicking it and selecting New. Give it a name and modify its borders to suit.
I suspect you’re inserting a Drawing Objects into your Writer document. Drawing objects are difficult to “sync” with text, particularly in the case of arrows because they can be attached to a single location while an arrow needs two. And it is generally a bad (rather, non optimal) idea to do graphical inserts directly in Writer. Draw is better suited for the task and Draw has specific styles adapted to graphics, notably when your drawing is “complex”.
To make things worse, drawing objects can’t be controlled by styles. Though the object itself is seen as similar to a frame (same parameters), no frame style can be applied (this would only solve the position issue, not the look).
Tell us more about your use of “lines”. In some cases, there may be a “pure text” solution without drawing objects (but does not apply to arrows).
And, as usual, for best suggestions, mention OS name, exact LO version and save format.
I make arrows to link different things, text to text, or text to image.
Exemple : https://snipboard.io/5NQlzV.jpg
So I’ll always draw a different arrow (different origin, destination and curve).
But what remains the same is : color, thickness, kind of arrow.
So what I want is : draw the arrow and click on a button to apply these properties, because it takes time, and I do it very often.
I succeeded with text (with a macro). But it seems harder with arrows.
As I mentioned in my previous comment, a limitation of Writer is: any drawing object or frame can be anchored to only one location in text. You can’t put a constraint between for a drawing object “linking” text-image to text-image.
However you can work around this limitation. Usually you don’t decorate your main topic with arrows to some illustration. Arrows are rather part of a larger drawing, even when you have text (called labels).
Such “complex” drawings can easily be created and updated in Draw. You put your shapes and labels (text boxes) where they look best. Then you add connectors (not simple lines) between your objects (shapes or text). Connectors have an interesting property: when you rearrange your objects for clarity or aesthetics, connectors follow the objects because they are glued to them. You ne longer need to modify the connectors to the new layout because this is done automatically (with smart routing).
Once you are satisfied with your design, you select the collection of your objects (or a selection of them – you can have several drawings in a slide; Draw is then used as a scratchpad for your Writer document) either with a menu command or by swiping the mouse over the objects (starting in free area), you copy the selection and paste it into Writer.
The operation automatically groups the objects so that you have a single one in Writer where you can tune the position properties (I recommend you don’t do it with the mouse so that the drawing can react to editing changes as if it were controlled by a frame style). Here is an example:
The drawing has been completely separated from the main discourse. The various boxes, lines and texts are all formatted with dedicated Draw styles so that all illustrations are consistent over the document. Then the image is anchored to the caption paragraph and set so that it is above the paragraph and centred horizontally.
If text above the image grows, the caption+drawing is moved downwards but still considered as an atomic block. If there is not enough room in the page, the block is flushed to next page, leaving (large) blank space. The image is never separated from its caption. (By the way, I didn’t Insert → Caption because it uselessly creates extra frames which I would have to manage explicitly.)
This is what Draw styles are for.
Ok. Thaks for all. But the anchor of the line is not the subject.
I just can’t find the styles that apply to lines, il they exist in the version 26.2.3.2 of LibreOffice running in Windows 11.
When I select the line and click on “Edit style” in the Styles panel, it opens the “Syle of paragraph”.
I think Writer does not have such styles.
That’s why I’m trying to write a macro to apply all the changes to the line.
Here is an exemple of what I’m looking for : the macro below changes the font family ant size at once.
sub Verdana_10
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FontHeight.Height"
args1(0).Value = 10
args1(1).Name = "FontHeight.Prop"
args1(1).Value = 100
args1(2).Name = "FontHeight.Diff"
args1(2).Value = 0
dispatcher.executeDispatch(document, ".uno:FontHeight", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(4) as new com.sun.star.beans.PropertyValue
args2(0).Name = "CharFontName.StyleName"
args2(0).Value = ""
args2(1).Name = "CharFontName.Pitch"
args2(1).Value = 2
args2(2).Name = "CharFontName.CharSet"
args2(2).Value = -1
args2(3).Name = "CharFontName.Family"
args2(3).Value = 0
args2(4).Name = "CharFontName.FamilyName"
args2(4).Value = "Verdana"
dispatcher.executeDispatch(document, ".uno:CharFontName", "", 0, args2())
end sub
I just need to replace the properties, like “FontHeight.Height”, by line properties.
I’m not the first one to create such macros. There must be a place where they are listed.
Because, as you rightfully noticed, there are no such styles in Writer. This is why I create all my illustrations in Draw, which I already mentioned several times.
IMHO, you’re on a wrong track. You’re trying to recreate in Writer what is available in Draw and probably much better than your macro, even after improvement.
Of course it might look a nuisance to switch to Draw to make/update a schema and to paste it back into Writer. However, consider the benefits of applying styles and the possibility to specify constraints on objects (like aligning them, grouping, attaching connectors, …). In the end, it is easier in Draw and you only handle a single “block” in Writer instead of a collection of “unrelated” drawing objects.
It is a different workflow. You need to get accustomed to it to appreciate the advantages. Separate the jobs: what is graphical goes into Draw (event the text block you relate with connectors or “arrows”), what is text, I mean an argumented discourse, excluding shape labels) goes into Writer.
This costs you no extra resource because the graphics engine is already in LO core. Writer has a very poor and reduced UI to it while this UI, including graphical styles, is provided by Draw.
The documents I create are not illustrations.
It is mostly text, and sometimes, I add an image to explain.
Draw is not what I need.
Anchoring is relevan!
To get the line (an arrow) accepted as an AutoText entry it must be anchored as character and serlected as such…
See the attached rather sloppy example.
Of course, the AutoText I worked with isn’t availabe for you because AutoText is stored to the user profile.
You need to create a new entry with the As-Character-Line as its only content.
disask_136127_arrowstyle_in_writer.odt (40.9 KB)
= = =
What are your arrows for?
If they shall point out any kind of relation between text portions, how would you keep your text consistent if something is to be inserted or cut out, if page size is changed and a new wrapping is needed,...?
Arrows can’t be used instead of cross references.
I loose less time opening the line properties and change 4 properties than I would if I had to draw a schema each time.
I just need to locate the place where properties like “FontHeight.Height” are described.
Have you looked at my sample screenshot? The document is mostly text. The image is there to ease understanding of the text. Using Draw and Writer is equivalent to using simultaneously keyboard and mouse. I never meant that Draw would replace Writer (it can’t). Draw is a complementary (and complimentary) tool to Writer.
It is the same strategy as adding Writer tables with simple formulas or inserting a full-fledged spreadsheet from Calc into Writer. Much more flexibility and power in Calc, notably with cell styles which don’t exist in Writer.
You don’t seem to be convinced. To avoid sterile development on this topic, I won’t add more comments.
Something like this? Only put cursor to line and run macro, it selects the line automatically.
I suppose the thickness is bold; constants for .CharWeight are in LibreOffice SDK.
But I don’t know what the same arrow means.
Sub changeProps
dim oDoc as object, oVCur as object, undoMgr as object
const cUndo="macro ChangeProps" 'text in Undo/Redo
oDoc=ThisComponent
undoMgr=oDoc.UndoManager
undoMgr.enterUndoContext(cUndo) 'only one step for all changes in Undo/Redo
oVCur=oDoc.CurrentController.ViewCursor 'visible cursor
with oVCur
rem select line
.gotoStartOfLine(false)
.gotoEndOfLine(true)
rem change properties
.CharColor=RGB(50, 221, 25)
.CharWeight=com.sun.star.awt.FontWeight.BOLD
end with
undoMgr.leaveUndoContext(cUndo) 'close the control of Undo/Redo
End Sub
Yes ! It is the kind of thing I need.
But it doesn’t work : the command .gotoStartOfLine(false) is in error :
Type: com.sun.star.uno.RuntimeException
Message: no text selection.
Same for the command .gotoEndOfLine(true)
And if I comment both, nothing happens.
Perhaps I didn’t quite understood you.
How can you “put cursor to line and run macro” since you need your cursor to run the macro (and then, the cursor is no more on the line) ?
It is normal visible cursor (mouse cursor), so normally click by mouse to text (line you want to change).
OP does not try to modify some text formatting but the properties of a line drawing object.
Ok, my big error :-).
@MyosotisArae upload example ODT with 2 drawing objects, initial and final ones

