Page 1 of 1

Removing background from page with a macro

PostPosted: Sat Feb 03, 2018 5:57 am
by arutkows
Greetings;
I created an image, entered it to the gallery and wrote a macro which takes the gallery image and sets it as a background on each page of my document. That works fine.
However, there is no way to use the gallery to remove the background from each page. I know it can be manually done with Format/Page/Background setting the graphic back to color etc but I want to do this with a macro.
When I create the macro, it stops at the drop down list which asks for graphic or color. I tried the down arrow followed by a few TABs to get to the Ok button (avoiding mouse clicks) but no matter what I try the macro still stops at the drop down.
I have found a "quick and nasty" way to do this, simply by creating a blank image and using that as background but obviously this is not ideal. Any thoughts would be appreciated.
Mac OS X 10.11.4 OOo 4.1.1

Re: Removing background from page with a macro

PostPosted: Sat Feb 03, 2018 7:11 am
by FJCC
I assume you set the image to be part of the Default Page Style. Does this do what you want?
Code: Select all   Expand viewCollapse view
oStyleFamilies = ThisComponent.getStyleFamilies()
  oPageStyle = oStyleFamilies.getByName("PageStyles")
  oStd = oPageStyle.getByName("Standard")
  oStd.BackGraphicURL = ""

Re: Removing background from page with a macro

PostPosted: Sat Feb 03, 2018 9:57 am
by Zizi64
When I create the macro, it stops at the drop down list which asks for graphic or color.


II suppose, that you tried to record the macro but not to write. The macro recorder has a limited capability.

You need to study and use the API functions for your macros.
And suggest you to download, install and use one of the useful object inspection tools like the MRI or the XrayTool.

Re: Removing background from page with a macro

PostPosted: Sat Feb 03, 2018 4:11 pm
by John_Ha
I suggest you search the Macros and UNO API forum and check Andrew Pitonyak's book.

Re: Removing background from page with a macro

PostPosted: Sun Feb 04, 2018 2:04 am
by arutkows
Thanks everyone for posting replies.
Yes, Tibor was correct is assuming that I used the Record Macro function to "write" the macros. I have used this function very successfully in the past but obviously not where it involved selecting from a drop down menu.
I am not a programmer by any means so I tend to use provided tools only. I'll have a look at the suggested documentation. Thanks again.

Re: Removing background from page with a macro

PostPosted: Mon Feb 05, 2018 12:19 pm
by RoryOF
The Record Macro can give an outline, but often needs the intricacies to be hand coded, based on either OO BASIC or the OO API.