Results 1 to 2 of 2

Thread: Setting table row heights to minimum

  1. #1
    VBAX Regular
    Dec 2018

    Setting table row heights to minimum

    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
    .Rows(irow).Height = 0
    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
    End If


    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
    I didn't repeat the Dim as I have them in the table, and saved repeating here.

    Thank you!

  2. #2
    VBAX Regular
    Dec 2018
    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts