使用宏删除 PowerPoint 中 space 行的 table 行

Removing white space of table rows in PowerPoint using macros

我一直在努力修复超出幻灯片高度和宽度的 table 内容。为了做到这一点,我尝试缩小 table 中的文字大小(如图所示,字体大小从 14 更改为 9) 我打算使用的另一种技术是,通过降低高度(标记为蓝色)来消除 table 每一行中存在的多余 'white/empty space'。

请帮助我完善我的想法或任何信息来实现这一目标。

image

这利用了 PowerPoint 永远不会将行高缩小到小于单元格中包含的文本高度的事实。它将继续缩小文本,直到 table 适合幻灯片。

Sub CheckTableHeight()
  Dim oSlide As Slide
  Dim oShape As Shape
  Dim oTable As Table
  Dim Row&, Column&
  For Each oSlide In ActivePresentation.Slides
    For Each oShape In oSlide.Shapes
      If oShape.HasTable Then
        Set oTable = oShape.Table
        Do Until oShape.Height + oShape.Top < ActivePresentation.PageSetup.SlideHeight
          For Row& = 1 To oTable.Rows.Count
            oTable.Rows(Row&).Height = 5
            For Column& = 1 To oTable.Columns.Count
              oTable.Cell(Row&, Column&).Shape.TextFrame2.TextRange.Font.Size = (oTable.Cell(Row&, Column&).Shape.TextFrame2.TextRange.Font.Size - 1)
            Next Column&
          Next Row&
        Loop
      End If
    Next oShape
  Next oSlide
End Sub