Thread: [Solved] Multi line for AddTextBox
View Single Post
 
Old 03-02-2015, 09:58 PM
phamh phamh is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Oct 2014
Posts: 13
phamh is on a distinguished road
Default

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
Reply With Quote