Visio Guy

Visio Discussions => Programming & Code => Topic started by: PF4VisioGuy on September 05, 2018, 03:02:48 PM

Title: Master Icons Colorless when Stencil Opened with Code
Post by: PF4VisioGuy on September 05, 2018, 03:02:48 PM
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

(https://i.imgur.com/DDxO1v7.png)



If I open the same stencil manually it is colored
(https://i.imgur.com/2QruXlp.png)

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
Title: Re: Master Icons Colorless when Stencil Opened with Code
Post by: PF4VisioGuy on September 05, 2018, 03:45:46 PM
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

Title: Re: Master Icons Colorless when Stencil Opened with Code
Post by: Paul Herber on September 06, 2018, 03:06:33 PM
ribbon File -> Options -> General
Enable Live Preview in Shapes Window
is the option you are looking for.

Title: Re: Master Icons Colorless when Stencil Opened with Code
Post by: PF4VisioGuy on September 07, 2018, 01:00:39 AM
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
Title: Re: Master Icons Colorless when Stencil Opened with Code
Post by: JohnGoldsmith on September 07, 2018, 08:43:47 AM
Hi,
Where did the stencil come from?  Is it something you're able to share?
Best regards
John
Title: Re: Master Icons Colorless when Stencil Opened with Code
Post by: PF4VisioGuy on September 07, 2018, 12:46:08 PM
They are from Cisco
https://www.cisco.com/c/en/us/solutions/enterprise/design-zone-smart-business-architecture/cvd.html
Title: Re: Master Icons Colorless when Stencil Opened with Code
Post by: JohnGoldsmith on September 08, 2018, 08:21:49 AM
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
Title: Re: Master Icons Colorless when Stencil Opened with Code
Post by: PF4VisioGuy on September 08, 2018, 06:44:38 PM
Sorry, my bad, here is the link to the vss files
http://www.petenetlive.com/KB/Media/0001041/Cisco_CVD_icons_visio.zip
Title: Re: Master Icons Colorless when Stencil Opened with Code
Post by: JohnGoldsmith on September 09, 2018, 10:28:10 AM
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
Title: Re: Master Icons Colorless when Stencil Opened with Code
Post by: PF4VisioGuy on September 11, 2018, 03:09:02 AM
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!