#1
|
|||
|
|||
Height of all rows of all tables set as "at least".
Hi guys,
as in the title, I need a VBA code that sets height of all rows in all tables in document as "at least" but without changing the value of the height, so when the volume of text in the cell increases, the cell expands, but when it decreases the cell DOES NOT shrink. I would appreciate any help |
#2
|
|||
|
|||
Hi, Woocash_11! Try this:
Code:
Sub Tbls_Format_1() 'Format all tables in active doc. Dim oTbl As word.Table For Each oTbl In ActiveDocument.Tables oTbl.rows.HeightRule = wdRowHeightAtLeast Next oTbl End Sub |
#3
|
|||
|
|||
Hi vivka, thank you for this!
However I already tried something very similar and this one works exactly the same - it does change the parameter "exactly" to "at least", but it somehow changes the value of all rows to the value from the first row of first table in the document, and unfortunately it makes it unusable I also tried asking AI, but apparently those I asked didn't work with VBA codes very well |
#4
|
|||
|
|||
Code:
Sub Tbls_Format_1() Dim oRow As Row Dim oTbl As Word.Table For Each oTbl In ActiveDocument.Tables For Each oRow In oTbl.Rows oRow.HeightRule = wdRowHeightAtLeast Next oRow Next oTbl lbl_Exit: Exit Sub End Sub |
#5
|
|||
|
|||
Thanks gmaxey.
Maybe this would work if the tables are basic. Unfortunatelly it doesn't work when there are tables with vertically merged cells. |
#6
|
|||
|
|||
Unless the height of the rows has already been set to "At Least", or "Exactly", there is no way to determine the current height of the row. Querying the row height in VBA will return a value of "Undefined".
You will need to decide what the minimum height should be, then modify the code in post #2 to set the Height property |
#7
|
|||
|
|||
Quote:
In my work computer there were the script on the outside platform that was doing this without any problems, so I thought it might be possible via VBA code. Apparently I was wrong |
#8
|
|||
|
|||
Quote:
This is a decision that is usually taken at the time of designing the document, not applied after the fact when you already have tables with content and merged cells. |
#9
|
||||
|
||||
Try this version
Code:
Sub TableRowAtLeast() Dim iSize As Long, aCell As Cell, aTbl As Table For Each aTbl In ActiveDocument.Tables For Each aCell In aTbl.Range.Cells If aCell.HeightRule = wdRowHeightExactly Then iSize = aCell.Height aCell.HeightRule = wdRowHeightAtLeast aCell.Height = iSize End If Next aCell Next aTbl End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
Tags |
height, table rows, vba |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel 2003: VBA "Function" causes "#VALUE!" errors after running "insert/delete row" custom macro | Matt C | Excel Programming | 2 | 01-08-2022 06:03 AM |
Help get rid of weird default "lines" or "table" look in document that has no tables or lines | Tsavard | Word | 2 | 06-11-2018 09:08 AM |
Macro to delete all rows with the word "Total" | RandWald | Excel Programming | 4 | 11-28-2016 07:50 PM |
Word Macro to find and delete rows that contain adjacent cells containing "." | AlexanderJohnWilley | Word VBA | 7 | 11-08-2012 10:15 AM |
How to choose a "List" for certain "Heading" from "Modify" tool? | Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |