Macro to sort paragraphs

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
harveyab
Posts: 93
Joined: Sat Sep 06, 2008 11:15 pm
Location: WA, USA

Macro to sort paragraphs

Post by harveyab »

I tried to record a macro to sort my writer document (by paragraphs), but the recorder stops when the sort dialog opens.
So what command do I need to use to simply sort paragraphs?
I am writing in OOo BASIC.
(Doing a search for other posts brings up every sort of topic, it is sort of disappointing. Do you sort of see what I mean?)
Harvey
Harvey (harveyab)
OOo 3.3.0 on MS Windows XP --- Time drags so quickly.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macro to sort paragraphs

Post by Villeroy »

Run this and confirm that you really want to do that by hitting the Enter key.

Code: Select all

sub recorded_SelectAll_Sort
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SelectAll", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SortDialog", "", 0, Array())


end sub
;)
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
Post Reply