Removing background from page with a macro

Creating a macro - Writing a Script - Using the API

Removing background from page with a macro

Postby arutkows » Sat Feb 03, 2018 5:57 am

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
arutkows
 
Posts: 2
Joined: Sat Feb 03, 2018 5:43 am

Re: Removing background from page with a macro

Postby FJCC » Sat Feb 03, 2018 7:11 am

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 = ""
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7315
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Removing background from page with a macro

Postby Zizi64 » Sat Feb 03, 2018 9:57 am

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; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.8; AOO4.1.6
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.
User avatar
Zizi64
Volunteer
 
Posts: 8376
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Removing background from page with a macro

Postby John_Ha » Sat Feb 03, 2018 4:11 pm

I suggest you search the Macros and UNO API forum and check Andrew Pitonyak's book.
AOO 4.1.6, Windows 7 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.
John_Ha
Volunteer
 
Posts: 6830
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Removing background from page with a macro

Postby arutkows » Sun Feb 04, 2018 2:04 am

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
arutkows
 
Posts: 2
Joined: Sat Feb 03, 2018 5:43 am

Re: Removing background from page with a macro

Postby RoryOF » Mon Feb 05, 2018 12:19 pm

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.7 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29605
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests