Author Topic: Visio startup and default settings  (Read 26831 times)

0 Members and 1 Guest are viewing this topic.

AndrewJ

  • Jr. Member
  • **
  • Posts: 20
Visio startup and default settings
« on: June 19, 2013, 08:10:47 AM »
Hi guys!

Quick question: is there any way to automatically have a macro run when you load up Visio?

This is of interest to me because the Visio settings do not allow me enough control for how I'd like Visio to load up so I figured loading a macro could be a way to work around that.

Thanks in advance!
Andrew

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1726
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Visio startup and default settings
« Reply #1 on: June 21, 2013, 05:36:39 AM »
Well the macro has to run from a loaded document.

Visio has a Startup folder path setting, which you can get to via:

File > Options > Advanced > File Locations... > Start-up.

I set this, for example, to: "C:\Users\MyName\Desktop\TestStartup\"

I tried putting documents into this folder, but they didn't open when Visio started. Same with .VBS (vbscript) files--they didn't run either.

But executables (.exe) do run. So if you have the ability to turn a macro into an .exe one way or another, this might be a way to go.

There might be other types of files that you can get to run, but this is what I found out with a few quick tests.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

aledlund

  • Hero Member
  • *****
  • Posts: 1412
Re: Visio startup and default settings
« Reply #2 on: June 21, 2013, 07:00:04 AM »
To add to what Chris said, the only way to load something up before the 'document opened' event (which can be caught by a macro in the document) is to write an add-in.
al

vojo

  • Hero Member
  • *****
  • Posts: 1589
Re: Visio startup and default settings
« Reply #3 on: June 21, 2013, 08:10:56 AM »
This raises an interesting question:   Since at least visio 2003 allowed you to start visio...THEN....select or create a doc.....and since
the old user group web site had a bunch of ways to start visio and pass it parameters, are we sure there is not a way (passing a parm to do something or a "visio loaded successfully...no doc opened" event) that one could intercede here.

For example, if you make a template, I would think starting visio from scratch would / could have the template as an option (like
block diagram metric).   If true, then there must be a way to "flavor" visio before doc opened.

Just a question

aledlund

  • Hero Member
  • *****
  • Posts: 1412
Re: Visio startup and default settings
« Reply #4 on: June 21, 2013, 12:01:18 PM »
what the template's traditionally did was to embed a 'persistent event' in the template document which would take advantage of the 'queue marker add-in'. These persistent events are usually flagged with two events, a document opened event,  and a document created event to fire off whatever process was need by the user created add-in. In either case it is a handshake between two add-ins that start when visio is activated and before a document is created/opened.
You're correct though that you can start visio with a command line that includes options. And after a document is opened with embedded macros, the macros can query what the start options in the command line were. However to use this technique you will have already opened a document and probably taken advantage of the 'doc opened' event to fire off your investigation of what was in the command line.
:-)
al

AndrewJ

  • Jr. Member
  • **
  • Posts: 20
Re: Visio startup and default settings
« Reply #5 on: June 27, 2013, 03:49:13 PM »
Thank you all for the great insights!
Now here's a tricky one.
Based on what you said, if I had a macro code:

Sub Test ()
      Hello
End Sub

and I wanted to run this macro upon loading Visio without opening a document or after selecting a blank Template for example, what would I need to do exactly?

Thanks in advance!
Andrew

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: Visio startup and default settings
« Reply #6 on: June 28, 2013, 01:39:26 AM »
VBA-Code has to be located in a document. A document in this context can be a drawing, a template or a stencil. When starting Visio you don't have any document open, so you can't start any code. That's what the others tried to explain. If the code should start without a document being open, you have to create an AddIn or AddOn.

That being said...
...here's a workarround:
Create an empty drawing. Place your code to be triggered with the document opened event. At the end of your code, don't forget to close the drawing, as it is only a dummy container for the code.
Create a new link to the Visio Exe on your desktop (eventually deleting the existing one). You can add a starting parameter to the link, so Visio always starts with your Dummy-Drawing when started via that new Desktop link.


Another method could be to create templates for everykind of drawing you want to create in your environment and to place your code in the Document Created and Document Opened event of every template. So whenever someone starts a new drawing from one of your templates or opens an old drawing based on such a template, your code will fire.


AndrewJ

  • Jr. Member
  • **
  • Posts: 20
Re: Visio startup and default settings
« Reply #7 on: July 02, 2013, 01:33:46 PM »
Hi Jumpy I understand,

But it's such a pain!
I'm trying to establish an easy way for people to all manage and load documents in the exact same way. Visio really should have better support from Microsoft and we should have more control over what options we want when Visio loads up.

But that aside, I have thought about your method of loading the document first, but since it would have to be done on every single computer, I'm not sure it's the best option.
Is there a link on how to write add-ins for Visio, and then load them? And would it be similar coding that is used in macros?

Also, for your Template idea, how can this be done?
I like the idea very much because when you open Visio, it gives you the choice to select a basic diagram, bpmn, blank document etc. and then you chose US or metric units. However, I don't see how I could create and load a Template in that screen. Are there instructions somewhere on how to do that? It could possibly be the most feasable workaround.

Thanks!
Andrew

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: Visio startup and default settings
« Reply #8 on: July 03, 2013, 01:09:18 AM »
To write an AddIn you can use Visual Studio for example, and with VS you can use VB, so it could look similiar to what you already know. A good start would be to download the Visio SDK that has some examples on that.

A good book for starting coding you own AddOns is the old "Visio Developer's Survival Pack" from Graham Wideman.

As to the placing of templates and stencils: You can place them in a folder of your choice and in Visio you can find a dialog, where you can define Paths for Visio to search for templates in stencils. That way Visio should present them to you in the Startup area or in the shapes menu.

Afaik (in newer Visios) you can although use/write an msi installer mechanism to "register" your templates somehow with Visio. I read about it, but don't have any details on this. Maybe one of the Gurus here can share some insights?

AndrewJ

  • Jr. Member
  • **
  • Posts: 20
Re: Visio startup and default settings
« Reply #9 on: July 05, 2013, 10:31:17 AM »
Thank you!
I misunderstood what you meant about templates. Already tried that and ran into issues of having to send around a file etc.
I think I'll stick to macros. I already have a macro set up for numbering process boxes, so I might as well just integrate everything else in there.
You see I don't mind tinkering with Visio myself, as I understand it's not a priority to Microsoft and it's fun to learn new things.
However, the context of my work is to standardize a way of flowcharting using Visio and it therefore needs to be as simple as possible to pick up and use. I don't mind doing all the Macro programming etc. ahead of time, but it has to be user friendly. That here is my challenge.
Thank you for all the help guys, but so far the best option seems to be to make a comprehensive macro, put it in a text file and ask the employees to copy and paste it, then run it in developer mode.
Hopefully the next Visio will be more user friendly because the amount of steps required to accomplish basic functions here pose a bit of a risk considering this will be used in a company of 7000 employees.
Andrew