PowerPoint VBA - 使用宏插入符号

时间:2018-04-26 13:27:47

标签: vba powerpoint powerpoint-vba

我正在尝试从FontAwesome图标库中插入PowerPoint中的符号。 Unicode值示例 - f001 这是我的代码 -

Sub InsertSymbol()

        Dim txtBox As Shape
        Dim s As String

        s = "f" & "001"

        'Add text box
        Set txtBox = Application.ActivePresentation.Slides(1) _
            .Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
                Left:=100, Top:=100, Width:=100, Height:=100)

        'Add symbol to text box
        txtBox.TextFrame.TextRange.InsertSymbol _
            FontName:="FontAwesome", CharNumber:=s, Unicode:=msoTrue

    End Sub

错误 - 运行时错误13 输入Misatch。 有人可以解决这个问题吗?

1 个答案:

答案 0 :(得分:2)

SendAsync()需要CharNumber - 请参阅here

经过一些研究 - 您的Unicode值long需要从十六进制转换为十进制。任何在线十六进制到十进制转换器都会为您提供相应的值"F001"hex to decimal converter