Convert table to text - macro ?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Convert table to text - macro ?

Post by BubikolRamios »

OO Writer Table/convert/table to text
How to do that with macro ?

Just template for further use - finds all tables in doc and removes last column in each table.

Code: Select all

Doc = ThisComponent
 TextTables = Doc.getTextTables() 
 For I = 0 to TextTables.count - 1
   Table = TextTables(I)
   Cols = Table.getColumns	
   Cols.removeByIndex(Cols.count-1, 1)
 Next
OPen office 4.1.5/ win 7
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Convert table to text - macro ?

Post by FJCC »

I recorded a macro to find the dispatcher call for converting a table to text and then I merged that with your code. Note that the For loop runs backwards because the number of tables in the document decreases with every loop, since they are being converted to text.

Code: Select all

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Delimiter"
args1(0).Value = CHR$(9)

Doc = ThisComponent
Cntrl = ThisComponent.CurrentController
TextTables = Doc.getTextTables()
For I = TextTables.count - 1 to 0 step -1 
   Table = TextTables(I)
   Cntrl.select(Table)
   dispatcher.executeDispatch(document, ".uno:ConvertTableToText", "", 0, args1())
Next
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Lupp
Volunteer
Posts: 3552
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Convert table to text - macro ?

Post by Lupp »

Just for info: There is a complete(?) list of LibO dispatch commands here: https://wiki.documentfoundation.org/Dev ... chCommands. There may be a few differences as compared with AOO, but hopefully not too many.
What I am missing is a concise description of the parameters (args). The .NAMEs a command understands would already help a lot. Who knows a uisable source?
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply