我需要一个 vba 代码来显示 powerpoint 中所选形状的 rgb 颜色

I need a vba code for display a rgb color for selected shape in powerpoint

我是ppt新手vba,以前只用word记录宏

我需要帮助通过 vba 代码

为 powerpoint 2013 中的选定形状获取 rgb 颜色

这将帮助您入门:

Dim oSh As Shape
For Each oSh In ActiveWindow.Selection.ShapeRange
    With oSh.Fill
        Debug.Print .ForeColor.RGB
    End With
Next

这是将上面.RGB 返回的Long 转换为R、G、B 分量的例程。你需要在这里:

Sub LongColorToRGB(ByRef lRed As Long, _
    ByRef lGreen As Long, _
    ByRef lBlue As Long, _
    ByVal lRGBColor As Long)
' Note:  if long > 16777214, returns 255s for all three values
' Note:  be sure to dim your variables in the routine that
'        calls this sub

pRed = pRGBColor Mod 256
pGreen = pRGBColor \ 256 Mod 256
pBlue = pRGBColor \ 65536 Mod 256

End Sub