我有一张包含大约10张幻灯片的PowerPoint,每张幻灯片都有一张需要以相同方式格式化的表格。我使用下面的宏来格式化表格中的文本,但我不知道如何将此代码与其他格式(如行高和表位置)结合起来。
有人可以通过在以下代码中添加以下首选项来帮助我:
所有文字中间对齐(垂直)
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
答案 0 :(得分:0)
我已经玩了一些,我已经回答了我自己的问题:
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
答案 1 :(得分:0)
我看到你想通了(干得好!)。另一个与您的需求相关的有用的事情"所有行高尽可能小"就是这样做:
oSh.Height = 0
...有时候会有几次,具体取决于表格的内容。