PDA

View Full Version : [SOLVED:] Setting table row heights to minimum



RayKay
02-04-2019, 03:09 AM
Hi John, and readers

I've spent hours trying different code, and using the VBA editor in PPT, but to no avail.

Basically I have a tool that formats a table to white with grey divider lines, however, I want to drop in code that sets all rows to the minimum height. Code I've ended up with is:

Dim minW As Single
With ActiveWindow.Selection.ShapeRange(1).table
For icol = 1 To .Columns.Count
For irow = 1 To .Rows.Count
With .Cell(irow, icol).Shape.TextFrame
End With
Next
.Rows(irow).Height = 0
Next
End With

Also tried:

Dim otbl As Table
Dim lRow As Long
Dim lCol As Long
Dim oSh As Shape
If oSh.HasTable Then
Set otbl = oSh.table
For lRow = 1 To otbl.Rows.Count
For lCol = 1 To otbl.Columns.Count
oSh.Height = 0
Next
Next
End If

And

Set Shp = ActiveWindow.Selection.ShapeRange(1)
iHeight = Shp.Height
iWidth = Shp.Width
Shp.Height = 0.001 * 72 * lHeight / lWidth
End If
I think this is about the tenth code I've edited a hundred times :banghead:
I didn't repeat the Dim as I have them in the table, and saved repeating here.

Thank you!

RayKay
02-04-2019, 03:21 AM
Hi John

I don't believe this! I figured it out, after 3 days' guessing! (I'm quite determined as I've learnt more thanks to you.)
I just solved in within two minutes! It's a great feeling!! This was my code, and I added the second line:

Set otbl = ActiveWindow.Selection.ShapeRange(1).table
otbl.Parent.Height = 0

I should have used Parent and not keeping looking at Row.
Have a great week :cloud9: