Visio Guy

Visio Discussions => General Visio => Topic started by: William Douglas on November 13, 2018, 10:17:37 AM

Title: Is there an easy way for other novice users to switch visible layers
Post by: William Douglas on November 13, 2018, 10:17:37 AM
Hello and good day everyone.

My first post here -
so please be patient
.

Have used Visio for many years (but a DIY learner, so totally green in many areas of it), and still stuck on Visio 2007. Hope this has a solution in that dinosaur.

I have a self facilitating roadmap template, have all the instructions assigned to one layer, and the user entry fields aligned with these in another layer.

The user may be Visio illiterate, or the menu structure may be different in later versions of Visio
How do I implement a single click button to achieve this ?
    [Menu [View [Layer Properties  {Toggle Visible.Content or Visible.TemplateInfo}

Is there even VBA macro support in Visio-2007?
And if so, was there anything user friendly like the [Record Macro] that Microsoft Excel provided - my quick and easy way to create starting point macro, from where I would modify it for my needs.

Thanks in advance,
Will
Title: Re: Is there an easy way for other novice users to switch visible layers
Post by: Paul Herber on November 13, 2018, 10:48:44 AM
VBA and macros have been in Visio from the year dot.
In Visio 2007 do:
menu Tools -> Macro
Title: Re: Is there an easy way for other novice users to switch visible layers
Post by: Paul Herber on November 13, 2018, 10:52:42 AM
From Visio 2010 onwards the menus have been replaced by the much-unloved ribbon. So, any UI feature for Visio 2007 will be different in Visio 2010 onwards.
Title: Re: Is there an easy way for other novice users to switch visible layers
Post by: William Douglas on November 13, 2018, 11:59:21 AM
Thanks Paul,

Recorded the two macros - not exactly self-explanatory in VBA (why don't my Layer names show?)

How can I link each macro to a button on the screen, else User has to be prompted to type  Ctrl^Q  and Ctrl^P   ?

Sub Content()
' Show content
' Keyboard Shortcut: Ctrl+Shift+Q
'   <snipped to kernel code />
    Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item(2)  'Template layer
    vsoLayer1.CellsC(visLayerVisible).FormulaU = "0"
    Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item(1) 'Content layer
    vsoLayer1.CellsC(visLayerVisible).FormulaU = "1"
Title: Re: Is there an easy way for other novice users to switch visible layers
Post by: William Douglas on November 13, 2018, 12:01:46 PM
So I'll test in V2010+ and report back here
Title: Re: Is there an easy way for other novice users to switch visible layers
Post by: vojo on November 13, 2018, 02:03:23 PM
is there a reason why you didn't use docmd(1446) in an action row in the shape sheet?

Action.layers = docmd(1446)

if you right click the shape or group of shapes (should check if it works at the page level), and select layers, it will
launch the layer dialog.   User can hide/show various layers.   when done, exit....if you need it again, repeat.
Title: Re: Is there an easy way for other novice users to switch visible layers
Post by: William Douglas on November 13, 2018, 02:57:10 PM
Yes - 2 reasons

1. Was on the path to use a macro to do this, intending to launch the macro from a button on the sheet.

2. Docmd(), action row, shapesheet - that's all jargon to me at this stage.
    I've used Visio to draft engineering diagrams until now, that's about it
    - Testament to how intuitively good the UI is, haven't needed to use anything but the visual elements until now.

But I'll try pick up on the jargon, it may well work better in this case
Title: Re: Is there an easy way for other novice users to switch visible layers
Post by: wapperdude on November 13, 2018, 07:27:34 PM
The Action section of the shapesheet allows you to create quick access actions.  These appear in the pop-up menu when you right click a shape. 

A good starting place is this (don't let the V2003 reference alarm you, it's still the same technique):  https://stackoverflow.com/questions/132860/how-do-i-add-an-action-to-visio-2003 (https://stackoverflow.com/questions/132860/how-do-i-add-an-action-to-visio-2003)

Explanation of the various entries of an Actions row:  https://docs.microsoft.com/en-us/office/client-developer/visio/actions-row-actions-section (https://docs.microsoft.com/en-us/office/client-developer/visio/actions-row-actions-section)

A good background on Visio is found here:  https://docs.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa165776(v%3doffice.10) (https://docs.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa165776(v%3doffice.10)).  This about the best document describing the full range of things Visio.  Explore it.

More recent shapesheet reference:  https://docs.microsoft.com/en-us/office/client-developer/visio/visio-shapesheet-reference (https://docs.microsoft.com/en-us/office/client-developer/visio/visio-shapesheet-reference)


Title: Re: Is there an easy way for other novice users to switch visible layers
Post by: William Douglas on November 14, 2018, 10:52:19 AM
Thanks wrapperdude,

Cos I had no joy finding any good V2007 helpfile stuff on action row, docmd, shapesheet.

I'll look through your ideas shortly.

For now the macro solution is working well, and it links to "buttons" quite easily.

A bit disconcerting that the macro name in the copy (for project name sanitization) references the original VSD file although a local copy actually is made.

Here's how to link the macro to the "button" - any shape will do, something that looks like a button makes more sense

Ok - inline images going to take a while to figure out, looks like must load on a hosting site and post the URL ..... for now as attachments

(http://U:%5C_Sav%5CVisio%20-%20link%20shape%20to%20macro%2001.Gif)

(http://U:%5C_Sav%5CVisio%20-%20link%20shape%20to%20macro%2002.Gif)