使用VBA设置自定义缩进和挂在Powerpoint表中

时间:2016-06-16 09:03:21

标签: vba powerpoint-vba

我想在powerpoint的表格中放置一个段落的子弹,然后在文本之前设置缩进:0.13和特殊/挂起0.13该子弹点。我能够实现这一点,但问题是,如果该表格单元格中有多个段落,则所有段落都会被给定的值所​​预期。

ActiveWindow.Selection.ShapeRange.TextFrame.Ruler.Levels(1).LeftMargin = 72 * 0.13 * 1

我使用的是完整单元格,而不仅仅是那个特定的段落。

ActiveWindow.Selection.TextRange.Paragraphs.IndentLevel = 3

我也尝试过使用IndentLevel,它仅适用于该特定段落,但在文本和悬挂之前我没有得到0.13的缩进值。有没有办法做到这一点? 我已经被困在这一整天。

1 个答案:

答案 0 :(得分:0)

您需要按如下方式迭代段落:

Option Explicit

' ********************************************************************************
' PowerPoint VBA Macro written by Jamie Garroch of http://YOUpresent.co.uk/
' Purpose : Set the Hanging ruler spacing for the selected text range
' Inputs  : None
' Outputs : None
' ********************************************************************************
Sub SetBulletHanging()
  Dim x As Long
  With ActiveWindow.Selection.TextRange2
    For x = 1 To .Paragraphs.Count
      With .Paragraphs(x).ParagraphFormat
        .FirstLineIndent = -72 * 0.13 * 1
      End With
    Next
  End With
End Sub