如何通过 Microsoft PowerPoint 宏设置文本框中各行的格式?
How do I format individual lines in a textbox via Microsoft PowerPoint macros?
我想要一个文本框,其中第一行和后续文本行具有不同的格式,但它们必须位于同一个文本框中。这是我目前拥有的,它对所有文本应用相同的格式。
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
文本应为 Arial 8。第 1 行应为黑色粗体,而后续文本应为蓝色。
.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
我想要一个文本框,其中第一行和后续文本行具有不同的格式,但它们必须位于同一个文本框中。这是我目前拥有的,它对所有文本应用相同的格式。
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
文本应为 Arial 8。第 1 行应为黑色粗体,而后续文本应为蓝色。
.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