Hi John / everyone
I've tried to make code that narrows all columns in a table to auto fit their text. But it goes one character wide per column.
Any ideas please? So columns will narrow to the width of its contents (unless text is wrapping of course, then that width is fine).
Thus the tables would be narrower in total width. If I change otbl.Parent.Width = 0 to Auto, it still fails. (Parent.Height = 0 works fine for table heights.)
Sub NarrowColumnWidths() Dim minW As Single With ActiveWindow.Selection.ShapeRange(1).Table Set otbl = ActiveWindow.Selection.ShapeRange(1).Table For iCol = 1 To .Columns.Count For iRow = 1 To .Rows.Count With .Cell(iRow, iCol).Shape.TextFrame otbl.Parent.Width = 0 End With Next Next End With End Sub
No sure if it's possible, I know you can in Excel and Word, just hoping this may do it?
Thank you.