如何通过 Microsoft PowerPoint 宏设置文本框中的单行格式?

the*_*edi 3 powerpoint vba powerpoint-2013

我想要一个文本框,其中第一行和后续文本行具有不同的格式,但它们必须在同一个文本框中。这就是我目前拥有的,它对所有文本应用相同的格式。

Sub geberateSlide() 
  ...
  With currSlide.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
  Left:=0, Top:=0, Width:=headerWidth, Height:=headerHeight)
    .TextFrame.TextRange.Text = "Test Box" & vbCrLf & "Description"
    .TextFrame.AutoSize = ppAutoSizeNone
    .Height = headerHeight
    .Line.ForeColor.RGB = RGB(0,0,0)
    .Line.Visible = True
  End With
...
End Sub
Run Code Online (Sandbox Code Playgroud)

文本应为 Arial 8。第 1 行应为黑色和粗体,而后续文本应为蓝色。

小智 5

.TextFrame.TextRange.Lines(0, 1) 将定位第一行。

在此处输入图片说明

%300 缩放

With currSlide.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
                                 Left:=0, Top:=0, Width:=headerWidth, Height:=headerHeight)
    .Height = headerHeight
    .TextFrame.AutoSize = ppAutoSizeNone
    With .TextFrame.TextRange
        .Text = "Test Box" & vbCrLf & "Description"
        With .Font
            .Color = vbBlue
            .Size = 8
            .Name = "Arial"
        End With

        With .Lines(1).Font
            .Color = vbBlack
            .Bold = msoTrue
        End With
    End With
End With
Run Code Online (Sandbox Code Playgroud)