First macros for page formating
First macros for page formating
Hi,
I trying to create macros (in LibreOffice) that when I'm open a document (single page document for example)
macros automatically formatting page size and margins, font family and size.
I use button "Record Macros" but when I use this macros the following is happen.
Macros open dialog window "page style: firs page" and if I want to go on I must enter margin values by hand.
After that macros do the next steps of the recording otherwise nothing is happen.
Never before I'm used macros.
I trying to create macros (in LibreOffice) that when I'm open a document (single page document for example)
macros automatically formatting page size and margins, font family and size.
I use button "Record Macros" but when I use this macros the following is happen.
Macros open dialog window "page style: firs page" and if I want to go on I must enter margin values by hand.
After that macros do the next steps of the recording otherwise nothing is happen.
Never before I'm used macros.
LibreOffice 5.4 on Windows 10
Re: First macros for page formating
Use a preformatted Template instead of the macros to achieve this task.
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.
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.
Re: First macros for page formating
I agree with Zizi64; all this information can be inserted into OpenOffice templates and it is a simple matter to start Writer documents with a custom template or choose one of a number of such templates. See
[Tutorial] Creating a new default template
[Tutorial] Creating a new default template
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: First macros for page formating
The macro recorder can not record all of the user's activity. You must WRITE your macros based on the API functions and procedures. API: Application Programming Interface. Start it with studying the Andrew Pitonyak's free macro books.I use button "Record Macros" but when I use this macros the following is happen.
Macros open dialog window "page style: firs page" and if I want to go on I must enter margin values by hand.
After that macros do the next steps of the recording otherwise nothing is happen.
Last edited by Zizi64 on Sat Nov 18, 2017 6:55 pm, edited 1 time in total.
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.
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.
Re: First macros for page formating
You might get away with reading the manual for OpenOffice BASIC at
https://wiki.openoffice.org/wiki/Docume ... ASIC_Guide
Be advised that macro programming in OpenOffice is not as simple as in some other office suites; OpenOffice is so powerful that frequently one can use its inbuilt facilities to achieve a desired end without any need for macro programming.
https://wiki.openoffice.org/wiki/Docume ... ASIC_Guide
Be advised that macro programming in OpenOffice is not as simple as in some other office suites; OpenOffice is so powerful that frequently one can use its inbuilt facilities to achieve a desired end without any need for macro programming.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: First macros for page formating
The most important thing that I want to do is not just to change page format (A5, A3 etc.) but margins too without writing new numbers for Left, Right, Top, Bottom.
This is the reason because of I trying to use macros. I found a little info but I don't know how to create macros to do this. Only this, because the procedure from the first post looks like too complicate.
So, in this case I could create two different macros:
a) one for page format include new margin and
b) another for paragraphs, text style, size.
The second one is easy, but how can I do the firs one?
_________
I am home user, not a pro neither a programmer. I have a lot of personal documents and I trying to edit most of them. I install LibreOffice before a week ago. I used FreeOffice 2016 before which was great for my simple tasks until now.
This is the reason because of I trying to use macros. I found a little info but I don't know how to create macros to do this. Only this, because the procedure from the first post looks like too complicate.
So, in this case I could create two different macros:
a) one for page format include new margin and
b) another for paragraphs, text style, size.
The second one is easy, but how can I do the firs one?
_________
I am home user, not a pro neither a programmer. I have a lot of personal documents and I trying to edit most of them. I install LibreOffice before a week ago. I used FreeOffice 2016 before which was great for my simple tasks until now.
LibreOffice 5.4 on Windows 10
Re: First macros for page formating
Create 2 templates and use either one depending on your needs.
Or switch between 2 page in one template.
Creating styles by means of macros is pointless.
Or switch between 2 page in one template.
Creating styles by means of macros is pointless.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: First macros for page formating
Look at this thread:
viewtopic.php?f=20&t=82036
I think there is a macro in that thread to set page margins, but honestly you would be better to use customised templates.
viewtopic.php?f=20&t=82036
I think there is a macro in that thread to set page margins, but honestly you would be better to use customised templates.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: First macros for page formating
OK. Let's forget macros for a moment.
I'm sorry but I don't understand you about a template.
When I create template and save as default it can be use for create a new document, isn't it?
But when I open existed document which was formatted before that, how can I use my template in this case to format existed document?
Do I miss something or this is impossible?
Ctr+O—>choose file—>open, so how to use template?
_____
By the way thanks for the link to the book.
I'm sorry but I don't understand you about a template.
When I create template and save as default it can be use for create a new document, isn't it?
But when I open existed document which was formatted before that, how can I use my template in this case to format existed document?
Do I miss something or this is impossible?
Ctr+O—>choose file—>open, so how to use template?
_____
By the way thanks for the link to the book.
LibreOffice 5.4 on Windows 10
Re: First macros for page formating
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: First macros for page formating
Backt to the API and the macros...
Always work with Styles instead of the direct formatting properties. It is much easier to automatize the adjusting procedure of the properties in the applied styles - than to get the manually formatted parts of a document, and to get and change theirs manually adjusted properties.
Are you using only one Paragraph Style (for example the Default paragraph style) in your documents???I trying to create macros (in LibreOffice) that when I'm open a document (single page document for example)
macros automatically formatting page size and margins, font family and size.
Always work with Styles instead of the direct formatting properties. It is much easier to automatize the adjusting procedure of the properties in the applied styles - than to get the manually formatted parts of a document, and to get and change theirs manually adjusted properties.
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.
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.
Re: First macros for page formating
If the intention is to change the formatting of an existing work or a small number of works, I suggest macros are not the way to go. Informed use of Find and Replace, rationalisation of the number of styles used and adjustment of their settings may be the way to go. I have downloaded a copy of War and Peace (550,000 words), removed the paragraph marks, set styles and formatted the entire book into normal book format in less than 15 minutes.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: First macros for page formating
Well it's not same like my small project but this is exactly that I want + new page dimensions and margins.RoryOF wrote:If the intention is to change the formatting of an existing work or a small number of works, ....................
...... I have downloaded a copy of War and Peace (550,000 words), ...... the entire book into normal book format in less than 15 minutes..
The second is a joke, right? I mean it's hard to believe, but well done.
Thanks RoryOF. Finely I found partial solution.RoryOF wrote:Look at this thread:
viewtopic.php?f=20&t=82036
I think there is a macro in that thread to set page margins, but honestly you would be better to use customised templates.
I don't understand almost nothing but the macros do what I want. I edited only margins value and after that macros changed the page size and margins just like I want.
In my case: A5; L,R,T,B = 0,8 cm.
I don't know how to edit this macros to change formats of paragraphs and characters so perhaps I'll trying the second macros.
Code: Select all
sub changeallpagesizesusedindocument
rem Portrait Sizes:
newpagesizeWidth = 14800 'this is my value
newpagesizeHeight = 21000 'this is my value
newTopMargin = 800 'this is my value
newBottomMargin = 800 'this is my value
newLeftMargin = 800 'this is my value
newRightMargin = 800 'this is my value
oViewCursor = ThisComponent.CurrentController.getViewCursor()
oViewCursor.jumptofirstpage(false)
do
s = oViewCursor.PageStyleName
oStyle = ThisComponent.StyleFamilies.getByName("PageStyles").getByName(s)
if oStyle.IsLandscape=True then 'this is for Landscape, the margins as if we rotated portrait 90°right, change as you like
oStyle.Width = newpagesizeHeight
oStyle.Height = newpagesizeWidth
oStyle.TopMargin = newLeftMargin
oStyle.BottomMargin = newRightMargin
oStyle.LeftMargin = newBottomMargin
oStyle.RightMargin = newTopMargin
else 'this is for portrait
oStyle.Width = newpagesizeWidth
oStyle.Height = newpagesizeHeight
oStyle.TopMargin = newTopMargin
oStyle.BottomMargin = newBottomMargin
oStyle.LeftMargin = newLeftMargin
oStyle.RightMargin = newRightMargin
end if
loop while oViewCursor.jumptonextpage(false)
oViewCursor.jumptofirstpage(false)
End Sub
LibreOffice 5.4 on Windows 10
Re: First macros for page formating
No, not a joke: in brief - I don't note all I do, but the major steps are - Modify Default page style to be A5, three passes of Find and Replace to remove extraneous paragraph marks and turn text into paragraphs, Select all text and apply Default Paragraph style; Find all chapter headings and format them with Heading I, Insert a ToC, set Headers on Default page styles. Autotext to change quotes to curly quotesLautrec wrote:Well it's not same like my small project but this is exactly that I want + new page dimensions and margins.RoryOF wrote:If the intention is to change the formatting of an existing work or a small number of works, ....................
...... I have downloaded a copy of War and Peace (550,000 words), ...... the entire book into normal book format in less than 15 minutes..
The second is a joke, right? I mean it's hard to believe, but well done.
Easy-peasy - I often do this to books I wish to print and bind.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: First macros for page formating
It is not a joke.The second is a joke, right? I mean it's hard to believe, but well done.
But you can not achieve this in a badly structured document. If the document contains lots of manual formatting properties: then you can delete them by a CTRL-A; Ctrl-M command pair...
But when the indents of the paragraphs was created by TABs (or by spaces!!!) and there are lots of other terrible "electric typewriter"-like formattings) then you must work more than 15 minutes...
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.
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.
Re: First macros for page formating
In fact, Zixi64, most "typewriter" like spacings can be removed by careful use of Find and Replace.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: First macros for page formating
Yes, it is true.In fact, Zixi64, most "typewriter" like spacings can be removed by careful use of Find and Replace.
But when the document contains only one paragraph style, and lots of the different size indents for the paragraphs, then you will/must play with it more than 15 minutes. (I had see such documents - unfortunately. )
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.
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.