I have a large document with pictures and i’d like to center all these pictures with a macro. what property of graphicobject do i need to set in order to achieve this?
thanks for your help
Are you sure you need a macro for that?
All pictures are inserted inside a frame which is controlled by a frame style. Usually, pictures are styled Graphics unless you specifically requested another frame style.
By default, anchor mode is To character. To paragraph is roughly equivalent in the majority of cases (the reference anchor point is the first character of the paragraph.
To center your pictures, modify the Graphics style:
- open the side style pane if not already there (
F11
) - click on the third icon in the toolbar to list the frame styles
- right-click on Graphics and
Modify
- go to the
Type
tab - in the Position section, set Horizontal
Center
toParagraph Area
- press
OK
That’s for theory. In practice, Writer does not always propagate immediately the frame style changes. In this case, the pictures must be “restyled” by selecting them and reapplying the style by double-clicking on the style name. This is where is macro may be handy. But refrain from applying the various attributes directly with a macro. This is strictly equivalent to direct formatting and will cause problems in the future should you change your formatting again. Prefer to apply a bare style with your macro.
I can’t give you code because I have never written a macro up to now (not having the need for it due to proper styling).
To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!
In case you need clarification, edit your question (not an answer which is reserved for solutions) or comment the relevant answer.
Do you need to select AutoUpdate on the ORGANISER panel to update all the existing Graphic Frames?
@petermau: very good point! Help tells this is related to direct-formatting and therefore I would stay away.
But the case of frame styles is special because they don’t really behave like other style categories. I update my answer.
Update: does not work always! Still need to reapply the frame style after change.