OO Writer Macros Usage

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Cliff S
Posts: 40
Joined: Mon Sep 07, 2015 2:54 am

OO Writer Macros Usage

Post by Cliff S »

Is there a way to combine or merge OO writer macros to work as one macro? I have a large group of documents that I wish to modify either in full or in parts. For example I have a different macro to Boldface text, change a font, delete a Date. I would like to run them as one macro. I am unable to find a capability to edit a macro.
Last edited by MrProgrammer on Wed Oct 30, 2019 7:21 pm, edited 1 time in total.
Reason: Moved from Beginners forum to Macros and UNO API
Open Office 4.1.1 on Windows 10
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OO Writer Macros Usage

Post by RoryOF »

You can Copy/Paste all your macros into a plain text editor, one after the other, then Copy/Paste the amalgamation back into the OO macro editor and add any extra code you need.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: OO Writer Macros Usage

Post by Zizi64 »

Please upload the parts of the macro code here.
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.
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: OO Writer Macros Usage

Post by JeJe »

Write a macro that calls the other macros

Code: Select all

sub runMacros1to3()
macro1
macro2
macro3
end sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OO Writer Macros Usage

Post by RoryOF »

@JeJe: Wouldn't they all need to be in the same library? That is why I suggested amalgamating them into the one unit, which leaves the individual macros functional in their files, in case that is ever needed.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: OO Writer Macros Usage

Post by JeJe »

Wouldn't they all need to be in the same library?
I'm not sure if that's a response to my post... but if the macros are in different documents then yes you may need to put them somewhere like the My Macros / Standard Library: you can't call a macro in one document from another document.

(If the macro is already in My Macros/some-library-name - then so long as the other library is loaded you can call the macro in it)
Last edited by JeJe on Wed Oct 30, 2019 10:53 pm, edited 3 times in total.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OO Writer Macros Usage

Post by RoryOF »

I edited my post to make it clear it was a reply to your post, JeJe.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
DiGro
Posts: 173
Joined: Mon Oct 08, 2007 1:31 am
Location: Hoorn NH, The Netherlands

Re: OO Writer Macros Usage

Post by DiGro »

I did the same with some macros of mine

I subsequently ran the macros be calling them from the previous executed one.

So macro 1 calls macro2, then macro2 calls macro3 etc...

Call the next macro just before closing the executed one, something like:

Code: Select all

previous executed code.....

Call SubMacro2()

End Sub
You can edit macros by using Tools > Macros > Manage Macros > OpenOffice Basic.
That will bring you to the Basic IDE where you can make en edit macro's
____________
DiGro

AOO 4.1.15 (Dutch) on Windows 11. Scanned with Ziggo Safe Online (F-Secure)
Cliff S
Posts: 40
Joined: Mon Sep 07, 2015 2:54 am

Re: OO Writer Macros Usage

Post by Cliff S »

Hi RoryOF At this point I believe that you had the best solution offered. Unfortunately I can't actually test it as another problem has occurred preventing testing it. The macro record function has ceased working. When I try and record a new macro it is no longer saving it. When I click save it appears to work and gives no error message or code. When I try to run that macro it does not appear in any of the folders. I'm going to have to solve this problem first. Also I checked the macro security function and found its set to medium. Tnx
Open Office 4.1.1 on Windows 10
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OO Writer Macros Usage

Post by RoryOF »

The OO Macro recorder is rudimentary; a recorded macro will often need to be hand edited to put the detailed functionality into it from the OO API information or the OO BASIC manual.

A quick search suggests that the macro recording functionality is only available for text documents in OOo Writer and for spreadsheets in OOo Calc. I cannot say how accurate this information is.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply