VBA 在 PowerPoint 中:更改文本颜色的 ColorIndex?

VBA in PowerPoint: ColorIndex to change textcolor?

我正在使用 VBA 将 Excel 中的数据复制粘贴到 PowerPoint 演示文稿中。现在我添加了一个文本框并想更改其中文本的颜色。使用 "vbBlack" 或 RGB

时有效
myPresentation.Slides(1).Shapes(1).TextFrame.TextRange.Font.Color = vbBlack

myPresentation.Slides(1).Shapes(1).TextFrame.TextRange.Font.Color = RGB(255, 0, 0)

但是,我可以为此使用 ColorIndex 吗?当我尝试时,它说它无法识别该方法。

Powerpoint 不包含 ColorIndex 属性 中的 ColorFormat. However, it does include the ColorConstants enum

您也可以使用SchemeColor or ObjectThemeColor

您需要将单元格设置为 ColorIndex,然后检索 Color 以获得 RGB 值。