Log in

View Full Version : How to hide blank rows in a Powerpoint table using vba macro?



Hemsat
04-05-2017, 09:09 PM
I'm new to VBA macros and trying to write a macro to hide the blank rows
in a Powerpoint table. I'm not sure which properties to use and how to
move on. Any help is highly appreciated. Thanks.


Sub TableRowHide()

Dim sl as Slide
Dim shTable as Shape
Dim pres as Presentation
Dim irow as Integer
Dim icol as Integer
Dim counter as Integer

Set pres = ActivePresentation

With sh.Table

For irow = 1 to .Rows.Count
counter = 0
For icol = 1 to .Columns.Count

If shTable.table.Cell(irow,icol).Shape.Textframe.Textrange.Text = ""
Then --------------

counter = counter + 1
End If

If counter = .Columns.Count Then --------

Else ------------

Next icol

Next irow

End With

End Sub

John Wilson
04-06-2017, 08:41 AM
Something like this maybe (for a selected table) NOTE blank rows are deleted - I don't believe you can just hide rows as you can in Excel.


Sub zap_emptyRow()
Dim otbl As Table
Dim iRow As Integer
Dim iCol As Integer
Dim b_Text As Boolean


On Error Resume Next
Set otbl = ActiveWindow.Selection.ShapeRange(1).Table
If Not otbl Is Nothing Then
For iRow = otbl.Rows.Count To 1 Step -1
b_Text = False
For iCol = 1 To otbl.Columns.Count
If otbl.Cell(iRow, iCol).Shape.TextFrame.HasText Then b_Text = True
Next iCol
If Not b_Text Then otbl.Rows(iRow).Delete
Next iRow
Else
MsgBox "Something is wrong!"
End If
End Sub

Hemsat
04-06-2017, 10:59 AM
Hi John,

Thanks for your script. As you indicated, this seems to delete rows rather than hide. I guess it's hard to hide the rows in Powerpoint unlike in Excel. Thanks a bunch!!

John Wilson
04-06-2017, 11:54 AM
Yep, there's no way to just hide rows. (That I know of!)