One*_*erd 5 vbscript powerpoint vba powerpoint-vba
我试图使用VBA将一些文本插入PowerPoint TextRange,我使用这样的东西:
ActiveWindow.Selection.SlideRange.Shapes("rec1").TextFrame.TextRange.Text = "Hi"
Run Code Online (Sandbox Code Playgroud)
但是,我无法弄清楚如何以编程方式应用粗体,斜体和下划线(我没有看到.RichText属性或类似的东西).
我所拥有的是一些简单的HTML文本,其中包含我想要转换的粗体,斜体和带下划线的文本.
这该怎么做?
这很容易通过使用完成TextRange的Characters,Words,Sentences,Runs和Paragraphs对象,然后它的Font对象来设置加粗,下划线和斜体(除其他性质).例如:
Sub setTextDetails()
Dim tr As TextRange
Set tr = ActiveWindow.Selection.SlideRange.Shapes(1).TextFrame.TextRange
With tr
.Text = "Hi There Buddy!"
.Words(1).Font.Bold = msoTrue
.Runs(1).Font.Italic = msoTrue
.Paragraphs(1).Font.Underline = msoTrue
End With
End Sub
Run Code Online (Sandbox Code Playgroud)