Delete (unused) pages containing only empty frames

Discuss the word processor
Post Reply
rdenbak
Posts: 4
Joined: Tue May 12, 2020 8:56 pm

Delete (unused) pages containing only empty frames

Post by rdenbak »

Hi, I have prepared a template document for booklets that have the original English text on the left (even) pages and the Dutch translation on the right (odd) pages.
To be able to work with two languages I've made empty pages with linked frames on the even pages and the same on the odd pages. In total 150 pages.
To make things a bit more complicated: every page has next to the main text frame also a narrow frame in which paragraph letters will appear. These also are linked in the same way.
See the attached document.

The first booklet now in preparation is a very small one (also to test if OpenOffice is really the way to go for us) and uses only 11 pages.
The rest of the pages now need to be deleted.

BUT: no matter how hard I tried: the pages only disappear when I manually select every single frame on each page and delete them, which is quite tedious.
Does anybody know a better way to do this?
Attachments
Empty Template EN-NL 150-pgs OO.odt
Example of the Template document
(21.42 KiB) Downloaded 135 times
OpenOffice 4.1.7 - Windows 10
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: Delete (unused) pages containing only empty frames

Post by JeJe »

This macro with delete all the text frames anchored to pages beyond page 11.

*To be on the safe side copy your document before running*.

Code: Select all

Sub DeleteTextFrames
en = thiscomponent.textframes 
for i = en.count - 1 to 0 step -1
c =  en.getbyindex(i)
if c.AnchorPageNo > 11 then  
thiscomponent.text.removetextcontent(c)
end if
next

End Sub
EDIT: CORRECTION PAGE NOS NOT ZERO BASED BUT ONE BASED.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: Delete (unused) pages containing only empty frames

Post by JeJe »

note correction.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Delete (unused) pages containing only empty frames

Post by RoryOF »

At one stage I considered a template of linked frames, much as the example file (with minor differences) for use with translation texts - one language on left, one on right. I did not proceed with the project, as I was able to find an old (150 yrs) printed copy of the text in question.

Rather than make a file of more pages than might be needed, with the need to delete the blank end pages (as in this case), I had contemplated writing a macro that generated a pair of new pages of the linked frames each time new pages were required.

Having acquired a copy of an earlier translation (borrowed from a library and photocopied), I did not need to proceed with the project.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
rdenbak
Posts: 4
Joined: Tue May 12, 2020 8:56 pm

Re: Delete (unused) pages containing only empty frames

Post by rdenbak »

JeJe wrote:This macro with delete all the text frames anchored to pages beyond page 11.
This is brilliant. Having come from MS-Office I did not immediately think of programming in OO.
The code (not surprisingly :D ) did indeed work, but I discovered that the pages did not immediately disappear because of the page-breaks on them (how else does one get new empty pages to put frames on :D )
Thanks JeJe for helping
RoryOF wrote:I had contemplated writing a macro that generated a pair of new pages of the linked frames each time new pages were required.
That's quite an idea as well, Thanks for your response as well, RoryOF
Might somebody has given this a go earlier, then I would be much interested, else it will likely become my first step into OO-Basic 8-)

All in all (being a novice in OO) OO feels like a very good replacement of MS-Publisher with many more capabilities, but also quite a steep learning-curve in some of it's areas.
OpenOffice 4.1.7 - Windows 10
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Delete (unused) pages containing only empty frames

Post by RoryOF »

I could not find that anyone had actually done this; having found a workaround (viz, borrowing a book from a library unbeknownst to the librarians over a long weekend) I did not have to proceed further with my plan.

Macro programming in OpenOffice/LibreOffice is not a trivial task; the best exposition is in the works of Andrew Pitonyak, which can be downloaded from http://www.pitonyak.org/oo.php

It is probable that most macros will not need further knowledge than contained in OO's BASIC; manual is at https://wiki.openoffice.org/wiki/Docume ... ASIC_Guide
so I suggest you start there.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply