如何缩进子弹ppt vba
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20248302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to indent bullet ppt vba
提问by user3018623
I'm having an issue with bullets in VBA on a text box in a PPT file.
我在 PPT 文件的文本框中遇到 VBA 中的项目符号问题。
I use the following code to modify existing text in bullets :
我使用以下代码修改项目符号中的现有文本:
PptDoc.Slides(3).Shapes(3).TextFrame.TextRange.Text = "1" & Chr(13) & "2" & Chr(13) & "3"
PptDoc.Slides(3).Shapes(3).TextFrame.TextRange.Text = "1" & Chr(13) & "2" & Chr(13) & "3"
It gives me :
它给了我:
- 1
- 2
- 3
- 1
- 2
- 3
I would like to make a sub bullet with "4" under the "3". I tried this :
我想在“3”下制作一个带有“4”的子项目符号。我试过这个:
.TextFrame.TextRange.Text = "1" & Chr(13) & "2" & Chr(13) & "3" & chr(13) & chr(9)& "4"
.TextFrame.TextRange.Text = "1" & Chr(13) & "2" & Chr(13) & "3" & chr(13) & chr(9)& "4"
It only gives me :
它只给我:
- 1
- 2
- 3
- {Some Space}4
- 1
- 2
- 3
- {一些空间}4
But id does not what I want. I tried with .IndentLevel, but never success.
但是 id 不是我想要的。我尝试使用 .IndentLevel,但从未成功。
Where am I wrong ?
我哪里错了?
Thanks for any help :)
谢谢你的帮助 :)
EDIT : I have tried some propositions, but it never works on my presentation here is what I tried :
编辑:我尝试了一些提议,但它从来没有在我的演示文稿中起作用,这是我尝试过的:
> .TextFrame.TextRange.Paragraphs(4).IndentLevel = 2
>
> .TextFrame.TextRange.Lines(4).IndentLevel = 2
Each time, it does absolutely nothing, I can see IndentLevel growing, but my bullet do not indent.
每次,它绝对什么都不做,我可以看到 IndentLevel 增长,但我的项目符号不会缩进。
回答by Shiva
You are seeing that extra space because you have chr(9)
in your original code and that is a Tabcharacter. So try vbCrLf
(which is carriage return followed by line feed) instead of the chr(13) & chr(9)
.
您会看到额外的空间,因为您chr(9)
的原始代码中有一个Tab字符。所以尝试vbCrLf
(这是回车后跟换行)而不是chr(13) & chr(9)
.
.TextFrame.TextRange.Text = "1" & vbCrLf & "2" & vbCrLf & "3" & vbCrLf & "4"
回答by JustinJDavies
I created a basic slide with a standard text box as the second 'Shape'. The following code indents the fourth line to the second bullet level (IndentLevel = 4
). Your IndentLevels may be specified differently but this should provide a generic framework from which a solution can be crafted.
我创建了一个带有标准文本框的基本幻灯片作为第二个“形状”。以下代码将第四行缩进到第二个项目符号级别 ( IndentLevel = 4
)。您的 IndentLevels 可能以不同的方式指定,但这应该提供一个通用框架,可以从中制作解决方案。
This works for me:
这对我有用:
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