如何使用VBA更改powerpoint 2013中选定内容的字体

如何使用VBA更改powerpoint 2013中选定内容的字体,vba,powerpoint-2013,Vba,Powerpoint 2013,我想将powerpoint 2013中的文本选择更改为粗体和“Courier New”。我尝试使用此VBA脚本更改字体: Sub chengeFont() With ActiveDocument.Selection With .Font .Name = "Courier New" End With End With End Sub 但它不起作用。有什么建议吗 这将更改字体,并在运行时将其加粗 With ActiveWind

我想将powerpoint 2013中的文本选择更改为粗体和“Courier New”。我尝试使用此VBA脚本更改字体:

Sub chengeFont()
    With ActiveDocument.Selection
        With .Font
            .Name = "Courier New"
        End With
    End With
End Sub

但它不起作用。有什么建议吗

这将更改字体,并在运行时将其加粗

With ActiveWindow.Selection.TextRange.Font
    .Name = "Courier New"
    .Bold = msoTrue
End With

由于您是从一个选择中运行它,因此文档应该始终是活动的,否则您需要更改
ActiveWindow

,我不确定,但我认为这与选择类似。style.fontfamine=“Courier New”。fontstyle=Bold或font.Bold=True这不适用于SmartArt graphics中的文本,你知道怎么避开吗?