Reputation: 11
I have a PowerPoint with about 10 slides, each slide has one table that needs to be formatted the same way. I am using the below macro to format the text within the tables, but I dont know how to combine this code with other formatting such as row height and table position.
Please can someone help me by adding to the below code the following preferences:
All Text middle aligned (vertically)
Sub format()
Dim s As Slide
Dim oSh As Shape
Dim oTbl As Table
Dim lRow As Long
Dim lCol As Long
For Each s In ActivePresentation.Slides
For Each oSh In s.Shapes
If oSh.HasTable Then
Set oTbl = oSh.Table
For lRow = 1 To oTbl.Rows.Count
For lCol = 1 To oTbl.Columns.Count
With oTbl.Cell(lRow, lCol).Shape.TextFrame.TextRange
.Font.Name = "Calibri"
.Font.Size = 7
End With
Next
Next
End If
Next ' Shape
Next s
End Sub
Upvotes: 0
Views: 8193
Reputation: 11
I have played around a bit more, and I've answered my own question:
Sub format()
Dim s As Slide
Dim oSh As Shape
Dim oTbl As Table
Dim lRow As Long
Dim lCol As Long
For Each s In ActivePresentation.Slides
For Each oSh In s.Shapes
If oSh.HasTable Then
oSh.Left = 1 * 28.3
oSh.Top = 3 * 28.3
oSh.Width = 23.5 * 28.35
oSh.ZOrder msoSendToBack
Set oTbl = oSh.Table
For lRow = 1 To oTbl.Rows.Count
For lCol = 1 To oTbl.Columns.Count
With oTbl.Cell(lRow, lCol).Shape
.TextFrame.TextRange.Font.Name = "Calibri"
.TextFrame.TextRange.Font.Size = 7
.TextFrame2.VerticalAnchor = msoAnchorMiddle
oTbl.Rows(lRow).Height = 0.5
End With
Next lCol
Next lRow
End If
Next oSh
Next s
End Sub
Upvotes: 1
Reputation: 2979
I see you figured it out (good job!). One other useful thing relating to your need "All row heights as small as possible" is to just do this:
oSh.Height = 0
...sometimes a couple of times depending on the table's content.
Upvotes: 1