Hear is function that will help us extract the RBG value of shape is any MS Office Application (Word, Excel, and PowerPoint).
The function returns two values, one as Text string and the other one as Hexadecimal value depending on the Boolean type you specify.
Paste the codes as below in any VBA mobule:
Function RBGExtract(myShape As Shape, IsHex As Boolean) As Variant c = myShape.Fill.ForeColor.RGB If IsHex = False Then redComponent = c Mod 256 greenComponent = c \ 256 Mod 256 blueComponent = c \ 65536 Mod 256 RBGExtract = "RGB components: " & redComponent & _ ", " & greenComponent & ", " & blueComponent Else RBGExtract = c End If End Function |
Now, its time to test the function that we have created, we will test it in PPT through following subroutine:
Sub Test() With ActivePresentation.Slides(1) MsgBox RBGExtract(.Shapes(1), True), vbInformation, 'To test the Hexadecimal value |
No comments:
Post a Comment