OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy |
Detect lines with gradient styles
I was asked a few days ago if there was a way to detect if a gradient line style is applied to a shape or not. Though I didn't find any native support to detect it. I did find a behavior that proved to be useful in detecting it. If a gradient line is set on a shape, if you try to set a different color to it, it won't take. See how this work for you.
Minimum required version: PowerPoint 2007
|
Dim rgbMangenta As Long Dim rgbOriginal As Long rgbMangenta = RGB(255, 0, 255) With ActiveWindow.Selection.ShapeRange(1) 'Store the original value of color rgbOriginal = .Line.ForeColor.RGB 'Assign a new value to it. .Line.ForeColor.RGB = rgbMangenta 'If the value doesn't take then the line style is gradient If .Line.ForeColor.RGB <> rgbMangenta Then MsgBox "Gradient line detected.", vbExclamation Else MsgBox "Gradient line not detected", vbExclamation .Line.ForeColor.RGB = rgbOriginal End If End With |
Copyright 1999-2022 (c) Shyam Pillai. All rights reserved.