How to place text on blank page?

Keyboard macros or custom scripts

How to place text on blank page?

Postby tommydog » Thu Jan 14, 2021 6:26 pm

I am using the below macro to produce automatic numbering on every line in writer. I have a document of blank pages that I wish to apply this numbering to, but the problem is when I run the macro, it does not write the numbering to the existing blank pages, but writes to new pages at the end of the document. How can I write to the existing blank pages?

attached is a sample of the blank pages that I wish to write to (various sizes and orientation). I need a quick way to do this, as in practice I will have hundreds of blank pages that need to have the numbering applied, and the order,orientation, size of these blank pages must be preserved.


Macro I am using:
Code: Select all   Expand viewCollapse view
Sub Main

    Dim i As long

    Do
        i = inputbox("How many lines you require?","Line Count")

    loop While not isNumeric(i)


    Dim oText
    oText = ThisComponent.Text

    Dim n   

    For n = 50 To i
        oText.insertString(oText.getEnd(), CHR$(13) & n & CHR$(9) , false)
    Next n

    Print "Done!"
End Sub
Attachments
blank pages.odt
(4.69 KiB) Downloaded 64 times
OpenOffice 4.1.8 on Windows 10
tommydog
 
Posts: 19
Joined: Wed Jan 13, 2021 2:24 am

Re: How to place text on blank page?

Postby RoryOF » Thu Jan 14, 2021 6:43 pm

I think the alterations you need for the macro are discussed on this page
https://wiki.openoffice.org/wiki/Writer/API/TextRange
Apache OpenOffice 4.1.10 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32546
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: How to place text on blank page?

Postby tommydog » Thu Jan 14, 2021 7:09 pm

RoryOF wrote:I think the alterations you need for the macro are discussed on this page
https://wiki.openoffice.org/wiki/Writer/API/TextRange


Thanks for your reply, however the only thing I can deduce from that is that the insertString parameter may have to be changed. I did not write the macro and know nothing about scripting, so if anyone could tell me what to change in the macro to achieve what I want to do then I would be very grateful.
OpenOffice 4.1.8 on Windows 10
tommydog
 
Posts: 19
Joined: Wed Jan 13, 2021 2:24 am


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 4 guests