1

我在 PPT 文件的文本框中遇到 VBA 中的项目符号问题。

我使用以下代码修改项目符号中的现有文本:

PptDoc.Slides(3).Shapes(3).TextFrame.TextRange.Text = "1" & Chr(13) & "2" & Chr(13) & "3"

它给了我:

  • 1
  • 2
  • 3

我想在“3”下制作一个带有“4”的子项目符号。我试过这个:

.TextFrame.TextRange.Text = "1" & Chr(13) & "2" & Chr(13) & "3" & chr(13) & chr(9)& "4"

它只给我:

  • 1
  • 2
  • 3
  • {一些空间}4

但是 id 不是我想要的。我尝试使用 .IndentLevel,但从未成功。

我哪里错了?

谢谢你的帮助 :)

编辑:我尝试了一些提议,但它在我的演示文稿中从来没有用过,这是我尝试过的:

> .TextFrame.TextRange.Paragraphs(4).IndentLevel = 2
> 
> .TextFrame.TextRange.Lines(4).IndentLevel = 2

每次,它绝对什么都不做,我可以看到 IndentLevel 增长,但我的子弹不缩进。

4

2 回答 2

0

您会看到额外的空间,因为您chr(9)在原始代码中有一个Tab字符。所以尝试vbCrLf(这是回车后跟换行)而不是chr(13) & chr(9).

.TextFrame.TextRange.Text = "1" & vbCrLf & "2" & vbCrLf & "3" & vbCrLf & "4"
于 2013-11-27T17:02:43.647 回答
0

我创建了一个带有标准文本框的基本幻灯片作为第二个“形状”。以下代码将第四行缩进到第二个项目符号级别 ( IndentLevel = 4)。您的 IndentLevels 可能会以不同的方式指定,但这应该提供一个通用框架,可以从中制作解决方案。

这对我有用:

Sub pleaseIndentBullets()

    Dim pres As Presentation
    Dim sd As Slide
    Dim shp As Shape
    Dim tr As TextRange

    Dim s As String

    s = "1" & Chr(13) & "2" & Chr(13) & "3" & Chr(13) & "4" ' Chr(9) is tab but this doesn't work
    Set pres = ActiveWindow.Presentation
    Set sd = pres.Slides(pres.Slides.Count)
    Set shp = sd.Shapes(2)
    Set tr = shp.TextFrame.TextRange
    tr.Text = s
    tr.Lines(4).IndentLevel = 4

End Sub
于 2013-11-27T17:03:12.043 回答