VBA Powerpoint - 如何突出显示选定的文本

VBA Powerpoint - 如何突出显示选定的文本

问题描述:

我想将所选文本突出显示为一种颜色,但这不起作用.你能帮我解决这个问题吗?

I would like to highlight the selected text into a colour but this is not working. Could you help me with that ?

Sub ShadingLtYellow()
    ActiveWindow.Selection.TextRange.HighlightColor.RGB = RGB(255, 255, 175)
End Sub

我还可以使用键盘快捷键(例如 Excel 上的应用程序 onkeys)触发宏吗?

Also can I trigger the macro using the a keyboard shortcut such as application onkeys on Excel ?

这会很棒

TextRange 用于向后兼容旧版本的 PowerPoint.对于当前版本(2010 及更高版本),请改用 Textrange2 对象,它具有突出显示:

TextRange is for backward compatibility with older versions of PowerPoint. With current versions (2010 and later), use the Textrange2 object instead, it has Highlight:

ActiveWindow.Selection.TextRange2.Font.Highlight.RGB = RGB(255, 255, 175)