Highlighted

Change row height limits

New Here ,
Nov 17, 2015

Copy link to clipboard

Copied

This is currently the final function in a script I have that finds empty rows in a document and deletes them. But in this instance, I don't want to delete them. I want to change the max and min row height limits of these empty rows.

function deleteEmptyRows (rows) {

  

var i, count = rows.length, row;

  

    for (i = 0; i < count; i += 1) {

        row = rows;

        if (rowIsEmpty (row) === true) {

              row.Delete ();

                        

        }

    }

          

}

I've got the cell dimension that I want to apply by running the below which gave me "371542". I thought I could just replace row.Delete (): with  row.RowMaxHeight="371542"; but this doesn't do anything. Could anyone point me in the right direction please?

var doc = app.ActiveDoc;

var pgf = doc.TextSelection.beg.obj;

var cell = pgf.InTextObj;

var row = cell.CellRow;

alert (row.RowMinHeight);



Cheers


Chris

Thanks for sending me the doc.

I found the problem:

RowMinHeight was higher than RowMaxHeight :760213

So you just have to add in my example above:

fRows.RowMinHeight=371542;

fRows.RowMaxHeight=371542;

TOPICS
Scripting

Views

1.9K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Change row height limits

New Here ,
Nov 17, 2015

Copy link to clipboard

Copied

This is currently the final function in a script I have that finds empty rows in a document and deletes them. But in this instance, I don't want to delete them. I want to change the max and min row height limits of these empty rows.

function deleteEmptyRows (rows) {

  

var i, count = rows.length, row;

  

    for (i = 0; i < count; i += 1) {

        row = rows;

        if (rowIsEmpty (row) === true) {

              row.Delete ();

                        

        }

    }

          

}

I've got the cell dimension that I want to apply by running the below which gave me "371542". I thought I could just replace row.Delete (): with  row.RowMaxHeight="371542"; but this doesn't do anything. Could anyone point me in the right direction please?

var doc = app.ActiveDoc;

var pgf = doc.TextSelection.beg.obj;

var cell = pgf.InTextObj;

var row = cell.CellRow;

alert (row.RowMinHeight);



Cheers


Chris

Thanks for sending me the doc.

I found the problem:

RowMinHeight was higher than RowMaxHeight :760213

So you just have to add in my example above:

fRows.RowMinHeight=371542;

fRows.RowMaxHeight=371542;

TOPICS
Scripting

Views

1.9K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 17, 2015 0
Enthusiast ,
Nov 17, 2015

Copy link to clipboard

Copied

Hi Chris,

this should work, but without quotation marks: row.RowMaxHeight=371542

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 17, 2015 0
New Here ,
Nov 18, 2015

Copy link to clipboard

Copied

Hi Klaus,

Unfortunately not, I've tried with and without quotation marks and still nothing.

Thanks

Chris

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2015 0
Enthusiast ,
Nov 18, 2015

Copy link to clipboard

Copied

Hi Chris,

I've just tested this and it works:

I have created a table, selected it and started this little script:

var gDoc = app.ActiveDoc ;

var oTabSelected = gDoc.SelectedTbl;

var myRow = oTabSelected.FirstRowInTbl;

myRow.RowMaxHeight=371542;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2015 0
New Here ,
Nov 18, 2015

Copy link to clipboard

Copied

I just copied and pasted this out and tried it over one of the tables in my document and it does'nt do anything. I get "Result: 371542" in the console and thats all. Could it be something to do with the formatting of the table?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2015 0
Enthusiast ,
Nov 18, 2015

Copy link to clipboard

Copied

Just try it first with an empty new table to make sure it works in general.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2015 0
New Here ,
Nov 18, 2015

Copy link to clipboard

Copied

It works perfectly with new doc and new table. It must be something further back in the script that’s messing it up.

But if it was something further back then the delete command wouldn’t work in the first instance, but it does!

Would it help to see more of the script?

Thanks

Chris

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2015 0
Enthusiast ,
Nov 18, 2015

Copy link to clipboard

Copied

Hi Chris ,

I've just extended the script. Just compare it with your script.

var gDoc = app.ActiveDoc ;

var oTabSelected = gDoc.SelectedTbl;

var AllRows = [];

var myRow = oTabSelected.FirstRowInTbl;

while (myRow.ObjectValid())

        {

            AllRows.push(myRow);

            myRow = myRow.NextRowInTbl;

           

        }

   

    MinimizeRows(AllRows);

function MinimizeRows(fRows)

{

    for (var i = 0; i < fRows.length; i++)

        {

        fRows.RowMaxHeight=371542;

        }

}

I guess, it has something to do with your document.

Is there a chance, that you send parts of your document to me via PN so I can test that?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2015 0
Enthusiast ,
Nov 18, 2015

Copy link to clipboard

Copied

Thanks for sending me the doc.

I found the problem:

RowMinHeight was higher than RowMaxHeight :760213

So you just have to add in my example above:

fRows.RowMinHeight=371542;

fRows.RowMaxHeight=371542;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2015 0
New Here ,
Nov 18, 2015

Copy link to clipboard

Copied

That's done it!

Thanks a lot

Chris

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 18, 2015 0