在 Powerpoint 中设置缩进和悬挂的自定义值 VBA

Set custom value for indentation and hanging in Powerpoint VBA

我正在尝试使用 VBA 在 powerpoint 中为 table 中的单元格设置缩进和悬挂的自定义值。我正在使用下面显示的代码。

tb.Cell(1,1).Shape.TextFrame.Ruler.Levels(1).LeftMargin = 72 * 0.13
tb.Cell(1,1).Shape.TextFrame.Ruler.Levels(1).FirstMargin = 0

这里的 tb 是 table。如果单元格不为空,这可以正常工作。但如果单元格为空,则值不会改变。有没有办法实现这个。

您需要设置文本的段落格式而不是单元格边距。使用这些:

With tb.Cell(1,1).Shape
  ' Before
  .TextFrame2.TextRange.ParagraphFormat.LeftIndent = 72 * 0.13
  ' Hanging
  .TextFrame2.TextRange.ParagraphFormat.FirstLineIndent = 0
End With

您可以设置为每个段落不同,如下所示:

.TextFrame2.TextRange.Paragraphs(lStart, lLength).ParagraphFormat.LeftIndent