BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Shortcut keys for macros in stencils

Started by Gunner22d, March 07, 2014, 01:40:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Hi all.  I'm missing something really obvious.

I have a macro in a stencil.  I can run the macro from the editor just fine. I have assigned a shortcut key (Ctl+m).  When I press the shortcut key, the macro is not invoked.

This is part of a wider issue I have - about distrubuting some handy macros that I really need to run quickly, ie with a shortcut key.  I thought putting the code in a stencil was the right approach, I would be able to load he stencil and have the code available when I need it.

I've read the post on deploying code, but it is silent on shortcut keys. Any ideas on alternatives welcome.

Paul Herber

Check your macro security settings. If you are distributing your code then you should consider getting a code signing certificate.
Electronic and Electrical engineering, business and software stencils for Visio -


Thanks Paul

My security settings are wide open, and I want to invoke a macro in a stencil via a key press.  Can I do this? What is the best way to do this?  Thanks.


I think shortcuts can invoked macros only in active document. External Stencil is not active document !


Thanks Surrogate.

I have a set of tools that I use for formatting shapes.  I like to use keyboard shortcuts.  I'd like to share them with friends. In Word, I can load a template into a known location, and when Word opens, the macros in this template are active for all Word documents.  I like this approach because it means that I can make changes to this template code, save it in the right place,  and then have it immediately available.  I'm looking for the nearest experience to this that I can get in Visio.

I see how I can load a macro in a template and attach it to a shortcut key.  I see how a document created from this template has a copy of this code (and shortcut) loaded. The important point is that this seems to be a copy of the code, because, when I change the code in the template, this is not available to my recently created document.  As far as I can see, I'd have to copy the new code into this document by hand for it to be available.

So the nuance is that I'd like shortcut keys and have some way of making code changes available in a fairly low touch kind of way. 

Many thanks for any suggestions.  :)


I use a combination:

The "working" code is in a stencil named code.vss, that contains no shapes, only the code, and is distributed to all users.
In the template is a reference to that stencil in the VBA project, so the stencil's code "is known" in the template/drawing.
That stencil is not visible in the template, because I don't have it open in the stencil explorer. It is only open because of the reference in the VBA project.
The code in the template can be started via Shortcuts and does nothing except starting the "working" code in the stencil.

So I can make code changes in the stencil and "only" need to distribute that stencil again, to make the changes available for all users.

If I want to create a completly new macro, I can distribute it with the stencil, so it's available for all, but you can't call that macro from older drawings, because there's no Shortcut available yet. The Shortcut is only available in new template/drawing.

So my solution is only a little bit better than yours because I can propagate code changes, but not entirely new code.


Another solution I'm thinking about:
- Scenario like above
- DocumentCreated or DocumentOpened event start a macro in the stencil.
- That macro creates a menu for all the available macros in the stencil.
- The menuitems get Shortcuts (don't know if that is possible)

So in theory the version of the stencil decides what code is available, as it should be.
Critical here is the last point: A way for the stencil to establisgh shortcuts....if it works.


Surrogate wrote: "I thisk [sic] shortcuts can invoked macros only in active document. External Stencil in not active document !"

True. Also, it seems that even if you import a *.bas macro file (into Modules VB directory) into a new active project/doc , the shortcut does not work in that project/doc although it appears in the Macros dialog (it only seems to work in the project/doc where the shortcut was originally created), as if shortcuts are actually stored in another area of the app... it can be made to work if you redefine it... but all of this (and more above) counteracts the purpose of macros.  I think these issues are due to the fact that MS did not create Visio from scratch like most of its other products, but acquired it and isn't bothering to update it with useful features.

So either I delve into VBA (loath) or forget about Visio macros... or perhaps Jumpy has come up with some code/process we can use effectively :)

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 253 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1148KB.
Tokens: post-login.
Cache hits: 13: 0.00122s for 26,763 bytes (show)
Cache misses: 2: (show)
Queries used: 16.

[Show Queries]