Macro to change style: toggle "print-object"

Hello coders,

bloody new to (LO) Basic, I am looking for a way to toggle the print-content style for a frame (background image) in LO writer. I’ve been researching for a whole day now and still didn’t find out, how to address this specific style.

Everything I tried beyond the following two lines resulted in errors:

Sub TogglePrintFrame
oFamilies = ThisComponent.StyleFamilies.getByName("FrameStyles")
oStyles = oFamilies.getByName("Graphics")
End Sub

Here the related XML snippet from the content.xml with the targeted variable quite at the beginning of line three:

1 <office:automatic-styles>
2 <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics">
3 <style:graphic-properties style:print-content="false" style:run-through="background" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="top" style:vertical-rel="page" style:horizontal-pos="left" style:horizontal-rel="page" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard"/>
4 </style:style>
5 <style:style style:name="fr2" style:family="graphic" style:parent-style-name="OLE">
6 <style:graphic-properties style:protect="content size position" style:vertical-pos="from-top" style:vertical-rel="page" style:horizontal-pos="from-left" style:horizontal-rel="page" draw:ole-draw-aspect="1"/>
7 </style:style>
8 </office:automatic-styles>

Any hints are very welcome - from what I’ve seen so far, I am somewhat optimistic to get remaining logic of the macro solved by myself -_-

Thank you,