Shape highlight colour / Highlight colour Visio 2013

Started by Rackers, December 17, 2019, 02:08:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rackers

Hi.

I am using Visio 2013 and I'm wondering if you can help with an issue I have. I've been trying to change the highlight colour when selecting objects, lines or groups of objects.

I came across this Macro on the forum:

Quote
Option Explicit

Public WithEvents WindowEvent As Visio.Window

Public Sub EnableEvents()
Set WindowEvent = Nothing
Set WindowEvent = ActiveWindow
End Sub

Private Sub Document_BeforeDocumentClose(ByVal doc As IVDocument)
Set WindowEvent = Nothing
End Sub

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
EnableEvents
End Sub

Sub ColorSelectedShapes()

Dim I As Integer

With ActivePage
    If .Shapes.Count > 0 Then
        For I = 1 To .Shapes.Count
            .Shapes(I).Cells("FillForegnd").Formula = "=RGB(255,255,255)" ' Make fill white
            .Shapes(I).Cells("LineColor").Formula = "=RGB(0,0,0)"         ' Make outline black
            Next I
        End If
    End With
   
With ActiveWindow
    If .Selection.Count > 0 Then
        For I = 1 To .Selection.Count
            .Selection(I).Cells("FillForegnd").Formula = "=RGB(255,255,0)" ' Make fill yellow
            .Selection(I).Cells("LineColor").Formula = "=RGB(255,0,0)"     ' Make outline red
            Next I
        End If
    End With
   
End Sub

Private Sub WindowEvent_SelectionChanged(ByVal Window As IVWindow)
ColorSelectedShapes
End Sub

Private Sub WindowEvent_WindowTurnedToPage(ByVal Window As IVWindow)
ColorSelectedShapes
End Sub

This seems to work for selecting single objects/lines but not when selecting groups of objects, there appears to be no highlight colour at all.

Is it possible to change the highlight colour for groups or do any of you know a better way of achieving this in Visio 2013?

Thank you

vojo

FYI...there are couple of bugs at group level.
Transparency makes all child shapes same color
Unless child shape protected, any group color change changes all child shapes

Rackers

Thanks,

There isn't any protection on the shapes that I can see.

Is there anything else I can try so that when I select shapes they have highlight a different colour?

Thanks again

Paul Herber

Your code only works on the top level of any grouped shape. If the shape is a group then you need to perform the same actions on the sub-shapes.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Rackers

Quote from: Paul Herber on December 18, 2019, 01:37:45 PM
Your code only works on the top level of any grouped shape. If the shape is a group then you need to perform the same actions on the sub-shapes.


Thank you.

Unfortunately I'm not great with writing Macros; this code came from another user on this forum.

Is there any chance you can assist with code for the sub-shapes?

Thank you

wapperdude

Search the forum for recursive.  This post ought to be useful, but there are quite a few others.  http://visguy.com/vgforum/index.php?topic=7286.msg30673#msg30673
Visio 2019 Pro