Flipping Tables

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Flipping Tables

Post by phspaelti »

NWP 2.0.5 introduced a number of new features for dealing with tables in macros. The following macro takes advantage of these features to improve on previous macros.

This macro will flip a table's rows and columns. It works for tables with different numbers of rows and columns, and it also works with tables that have merged cells. it also copies cell edge attributes, and it tries to preserve the size of the table and the relative widths and heights of the rows and columns, as far as possible.
Swap Rows and Columns.nwm
(22.93 KiB) Downloaded 794 times
Update: found yet another small bug. But fixed now.
Last edited by phspaelti on 2013-11-02 07:27:06, edited 4 times in total.
philip
NisusUser
Posts: 317
Joined: 2011-01-12 05:32:38

Re: Flipping Tables

Post by NisusUser »

Hi, Philip,

Good to see you're still practicing macro-writing :)

I tried this macro on a table (3x3) and it didn't work. Just left a shrunken table in the middle of the page. So then I inserted a table with no left upper box usable and tried the macro on it. Still doesn't work (same result).
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Flipping Tables

Post by phspaelti »

Thanks Eric.

The problem seems to be that Nisus treats the rows of a default table as having a height of 0. In such cases the layout engine seems to adjust the height as necessary. But my macro sets the dimensions (the width of the new table) according to that number. So you end up with a 0 width table. You could avoid that result by adjusting the height manually. That forces the table to take on a fixed height and the problem is solved.

Well, to avoid these complications I have replaced the macro with a version that automatically forces the height to be 1 in such cases. It's a kludge, but a small one :)
philip
NisusUser
Posts: 317
Joined: 2011-01-12 05:32:38

Re: Flipping Tables

Post by NisusUser »

Beautiful! Works as described! Way to go!
Post Reply