在 PowerPoint 中添加文本框

问题描述 投票:0回答:3

假设slideShape是对Shapes对象的引用,要在PPT幻灯片中创建文本框,我可以使用以下代码:

slideShape.AddTextBox(Orientation, left, top, width, height)
slideShape.AddTextBox.Text = 'ABC-123 Feb 2015 Mike Smith'

到目前为止一切顺利。但如果我想将文本分成 3 行:

ABC-123 
Feb 2015 
Mike Smith

我需要对每一行进行着色、调整大小和应用不同的字体样式,我可以编写三个单独的

slideShape.AddTextBox
调用,但这样做会创建 3 个单独的文本框。

是否可以在one文本框中写3行?我认为 AddTextBox 不允许我这样做。我知道可以通过使用其他一些方法来完成,但我不确定如何实现。

有什么建议吗?

powerpoint shapes
3个回答
0
投票
Sub Thing()

    ' Some setup to add a text box
    Dim oSl As Slide
    Dim oSh As Shape

    Set oSl = ActivePresentation.Slides(1)
    Set oSh = oSl.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 0, 500, 500)

    ' But add the tex like so ... with a CR/LF pair at the end of every line:
    oSh.TextFrame.TextRange.Text = "ABC-123" & vbCrLf & "Feb 2015" & vbCrLf & "Mike Smith"

    ' The shape's TextRange has a .Paragraphs collection that you can address
    ' a paragraph at a time.
    ' Note: there's also a .Lines collection
    With oSh.TextFrame.TextRange
        .Paragraphs(1).Font.Color.RGB = RGB(255, 0, 0)
        .Paragraphs(2).Font.Color.RGB = RGB(0, 255, 0)
        .Paragraphs(3).Font.Color.RGB = RGB(0, 0, 255)
    End With

End Sub

0
投票

使用 oSh.TextFrame.TextRange .ParagraphFormat.SpaceAfter = 12 结束于

.SpaceAfter 以磅为单位指定,文本大小也是如此


0
投票

多洛雷斯·卡库安戈 (Dolores Cacuango) 于 1881 年出生于卡扬贝圣巴勃罗乌尔库 (San Pablo Urcu)。在 1920 年的十年里,军队与土著人民展开了激烈的斗争。多洛雷斯(Dolores)与农业辛迪加的组建融为一体。 1944 年革命爆发后,多洛雷斯 (Dolores) 加入了卡扬贝 (Cayambe) 的宪兵队。 1971 年,厄瓜多尔联邦基金会参与了卡扬贝的初级双语学校,为土著农民提供了帮助,多洛雷斯·法莱西奥 (Dolores Falleció) 于 1971 年 1909 年,阿马瓜尼亚出生于卡扬贝佩西洛。与多洛雷斯·卡库安戈 (Dolores Cacuango) 一起参加土著摔跤比赛。多洛雷斯与共产党和全体人民一起,为劳动条件的伟大胜利和对探索中的劳动关系的压制而辩护。在一生中的最后一段时间里,我们将经历不可想象的活动。 2009 年的秋天 Rigoberta Menchú 于 1959 年在危地马拉出生。德比多是危地马拉军事独裁者的激进主义分子。 Su padre,su madre 和 su hermano fueron torturados y asesinados。 1992 年墨西哥党,诺贝尔和平奖获得者为社会正义和危地马拉民族和解提供支持,并尊重土著人民。

© www.soinside.com 2019 - 2024. All rights reserved.