Visio Layer Transparency

matthew cochrane
matthew cochrane used Ask the Experts™
on
Hi,
In Visio, is it possible using vba to show a layer at different levels of transparency (one after the other until the layer is fully visible)?
thanks
Matt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Visio Consultant, Trainer, Author, and Developer
Most Valuable Expert 2011
Commented:
Interesting idea, and the answer is yes. One thing to watch out for: the layer in question must have a color assigned (even if it's white) in order for the transparency setting to have any effect.

Sub SetLayerTransparency()
' sets layer transparency
' Scott Helmers,  http://www.VisioStepByStep.com, Scott@VisioStepByStep.com
'
' NOTES:
' 1) The CellsC property of the layer object takes an integer column number; the code below uses a predefined
'    enum to identify the color transparency column. Refer to the Visio SDK for enum lists, e.g.,
'       https://msdn.microsoft.com/en-us/vba/visio-vba/articles/layer-cellsc-property-visio
' 2) The value for color transparency must be <= 1

    Const sLayerName    As String = "TestLayer"
    Dim pg              As Visio.Page
    Dim lyr             As Visio.Layer
    
    Set pg = ActivePage                                     ' get active page
    Set lyr = pg.Layers(sLayerName)                         ' get desired layer
    lyr.CellsC(Visio.visLayerColorTrans).FormulaU = 0.5     ' set transparency to 50%
    
End Sub

Open in new window

Author

Commented:
Many thanks

Author

Commented:
Thank you Scott

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial