Ask Your Question
0

How do I make a button to apply a Table AutoFormat? [closed]

asked 2014-03-27 19:03:03 +0200

I have a document with a large number of tables in it, and I need to update the formatting on them all.

I have a Table AutoFormat already set up, with the settings I want. However, for each table I come across, I need to manually go to Table => AutoFormat => (Select Style) => OK.

Is there an easy way to make applying the style a one-click operation? I recorded a Macro of applying the style, but that doesn't seem to work.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-02-20 15:47:16.981578

1 Answer

Sort by » oldest newest most voted
0

answered 2014-03-28 21:39:12 +0200

mahfiaz gravatar image

When your searches on Google with LibreOffice don't give you satisfactory results, search for OpenOffice, it reveals a whole new level of ancient treasure.

I believe you searched for this topic:

https://forum.openoffice.org/en/forum...

I copy over the final answer by Tim Grantham in case that webpage is unavailable:

    // Get the TextTablesSupplier interface of the document
    XTextTablesSupplier xTableSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, xDoc);

        // Get an XIndexAccess of TextTables
        XIndexAccess xTables = (XIndexAccess)UnoRuntime.queryInterface(
            XIndexAccess.class, xTableSupplier.getTextTables());

    int tablecount = xTables.getCount();

    for (int i=0; i < tablecount; i++) {

        XAutoFormattable xAutoFormattable = ( XAutoFormattable ) UnoRuntime.queryInterface (
            XAutoFormattable.class, xTables.getByIndex( i ) );

        xAutoFormattable.autoFormat("simpletable_header");

    }
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-27 19:03:03 +0200

Seen: 157 times

Last updated: Mar 28 '14