Visio 2007 and Add-ons/ins

G

GMorris

Hi all,

I've just started using Visio 2007, and it's a great product from what I've
seen so far. One of the things I did was download the SDK so I could
fool with it in Visual Studio. Sure enough, there was a project type for
a Visio Add-on (or Add-in, can't recall now), and I opened one up in VB
to take a look.

Now, just as a test, I added a line of code to both of the event handlers
provided to display a MsgBox upon entry and exit from the Add-#n. Not
ever having written an external Add-#n for Visio, I wasn't sure how I
would need to include it in a project, and especially being .NET I had no
idea how to make it active in a Visio session, so I did the next logical
things: I built the tiny Add-#n, then once a successful build I closed VS
and then opened Visio to attempt to use it and display the messages.

To my surprise (and wondering eyes), as soon as I fired up Visio the
Add-#n was active! I got the MsgBox, dismissed it, and then began to
look around for it and how the heck Visio found and knew where it was.
Much less, why did Visio just assume that I built the Add-#n to be in any
project I open? I could not find the thing anywhere in Visio, and there
was even a list that it probably should have been in, but wasn't.

So, I guess the next thing to do is find out if anyone can tell me why this
happens (like a default or something), and how would one write an Add-
#n for a particular template or document and ONLY that template, etc.
What steps then to package it and run on someone else's Visio machine?
This is all a little confusing to me, as I was never good enough with C to
use the old Add-in templates that were provided, and at the time there
just wasn't support for any other languages that I could find anyway. It's
just blowing my mind why this little-bitty test of an Add-#n has been
"adopted" by Visio when I never even told it the thing exists! Any help or
direction to resources about this would be great. I've written apps in VBA
through the Visio IDE, but they are clunky and slow, buggy and difficult to
manage at best. I'd really like to master using VS to create some power
for Visio apps and at the same time take FULL advantage of the OO
capabilities of .NET rather than fight with Visio's VBA. Thanks.
 
D

David Parker

If you used the Visio COM add-in template, then this included the settings
for Visio.
If you are using VS 2008, then you can use the System.Addins namespace
instead.

In either case, the add-in is loaded at startup of Visio, but you can
include Persistent Events in a document or template so your add-in knows
when to bother adding more events. Use QUEUEMARKEREVENTS to communicate
between commandbars / shape actions and your add-in.
 
G

GMorris

Thanks for the tips guys, I'm reading about it now and will go through the
tutorial once to get a better grip on it. What I was wondering most about
is why Visio just automatically includes the Addin at startup, as I had
planned
to create an application, but wouldn't want it opening up in other Visio
scenarios. Like if I just wanted a blank drawing, I don't want all of the
functionality that the addin provides, much less the overhead. But how to
stop it from loading is what I'm looking for, so that it WILL load when
a user fires up a template for my Visio App but WON'T load if any other
drawing or template is being used. I guess I'll figure it out as I go
along..
 
A

AlEdlund

Greg,
What you're asking about typically is done with 'persistent events'. An
addin will monitor events such as 'document opened' and the code will check
to see if the document is flagged to be acted upon by the application (you
get to write that code), if not the document may be ignored. The examples
sometimes forget to let the new developer know that they have that
responsibility of managing those 'marker' events. This is one reason why
templates can be so powerful (the persistent event is defined in the
template).
al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top