Removing background from page with a macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
arutkows
Posts: 2
Joined: Sat Feb 03, 2018 5:43 am

Removing background from page with a macro

Post 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
OS X 10.11.4
OPen Office 4.1.1
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Removing background from page with a macro

Post 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

 oStyleFamilies = ThisComponent.getStyleFamilies()
  oPageStyle = oStyleFamilies.getByName("PageStyles")
  oStd = oPageStyle.getByName("Standard")
  oStd.BackGraphicURL = ""
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Removing background from page with a macro

Post 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.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Removing background from page with a macro

Post by John_Ha »

I suggest you search the Macros and UNO API forum and check Andrew Pitonyak's book.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
arutkows
Posts: 2
Joined: Sat Feb 03, 2018 5:43 am

Re: Removing background from page with a macro

Post 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.
OS X 10.11.4
OPen Office 4.1.1
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Removing background from page with a macro

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply