Master Icons Colorless when Stencil Opened with Code

Started by PF4VisioGuy, September 05, 2018, 03:02:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PF4VisioGuy

Hi guys

I am using this template "Basic Diagram.vst" to create a blank document programatically

I am using this call to open a stencil for the active document

self.stnObjWireless = self.appVisio.Documents.OpenEx("Wireless.vss", 4)

it looks like this





If I open the same stencil manually it is colored


why is this happening ? This is Visio 2010
I suspect it has something to do with the theme of the doc but trying to apply a random theme colors the shapes completely in one color

PF4VisioGuy

#1
It is indeed the theme but it is strange
If I open the doc and apply random themes and then I reset back to no theme the colors are coming back


Paul Herber

#2
ribbon File -> Options -> General
Enable Live Preview in Shapes Window
is the option you are looking for.

Electronic and Electrical engineering, business and software stencils for Visio -

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

PF4VisioGuy

#3
thanks for the reply
it was checked
if unchecked the stencil gets colors although distorted in some cases but the diagram created is still showing no colors

JohnGoldsmith

#4
Hi,
Where did the stencil come from?  Is it something you're able to share?
Best regards
John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/


JohnGoldsmith

Thanks for the link.  I couldn't find that LAN Switching stencil and the Wireless.vss stencil that I found here seems to be a different one: https://www.cisco.com/c/en/us/products/visio-stencil-listing.html
Best regards
John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/


JohnGoldsmith

When I manually open the LAN Switching stencil in a diagram based on the 'Basic Diagram' template (via More Shapes / Open Stenicl...), the stencil is rendered as per your top image (black and white).  This is expected as the template defines a "Basic colors, Basic shadow effects" theme (36 and 16 respectively).

If I manually open the same stencil in new blank diagram, or, set the Basic Diagram to 'No Theme' then the stencil icons are rendered as per your bottom image (red and blue).  This is also expected as these are the colors defined in the original masters - ie that is their default state.

Both of the above points apply to the Wireless stencil as well.

Note also, if you open the stencil file standalone (ie not docked within a drawing document) then you'll also see the master icons rendered as red and blue as no theme is applied that overrides these colors.

So the short answer is the master icons are rendered based on the theme applied to the page.  My assumption is that your second image is based on opening the stencil directly (ie undocked) or in a blank diagram - is that right?

To use the stencil with the 'Basic Diagram' template and have the original red and blue colors show up, start by setting the Page theme to none as follows:

Sub TestChangeThemeAndOpen()
    Dim stencilDoc As Visio.Document
    Dim vPag As Visio.Page
    Set vPag = ActivePage
    vPag.ThemeColors = Visio.VisThemeColors.visThemeColorsNone
    vPag.ThemeEffects = Visio.VisThemeEffects.visThemeEffectsNone
    Set stencilDoc = Application.Documents.OpenEx("C:\Users\MY_USERNAME\Desktop\Cisco_CVD_icons_visio\LAN Switching.vss", 4)
End Sub


Let me know if that helps.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

PF4VisioGuy

It will surely help because that is exactly what I was doing manually.(see the second post)
Thanks for the code and for looking into this!