Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a module/macro to Visio

Status
Not open for further replies.

karcs

Programmer
Aug 24, 2006
2
CA
Hello All,

I have written a little VBA module within a Visio document that I need to use on ALL documents I'll be opening with Visio.

I would like to avoid having to go to Tools-->Macros-->VBA Editor-->Import-->MyModule.bas for EVERY single document that I'll be opening. Is there any way to "install" this into my Visio application so it's just available to any document I open?

In other words, I just want to go to Tools-->Macros-->Run for a document. Or something even simpler would be good. I may need to install this on other people's Visio app who are not very technically inclined... and besides, it does become a pain to import this .bas module when dealing with many Visio documents at a time.

Thanks in advance to all who help!

-=K=-
 
I'm not a Visio programmer, by any strecth, but...

I took a look in the Visio SaveAs area. I don't see any form of addin for visio, unfortunately. You may be able to compile one using VB6 or VB.Net, but this is way out of my scope.

There is also no version of "Normal.dot" (word) or the "personal.xls" (excel) that I can see to save generic code in either. Even when you leverage the macro recorder, all you see is the option to store in "ThisDocument".

Truly Visio seems short of functionality for this kind of thing.

I did see that you can create a template though. With that, you could create a new document, drop your code in there, and save it as a template. Base any new documents on that template, and they will inherit the code (at least, if they work like other Office apps, anyway.) At least you can get it going forward.

Another alternative, since Visio can have more than one document open at a time, may be to create a file that also has a routine in it to import a module into any other open file, if it needs it. You can find code to import modules here: This could at least reduce the clicking.

Sorry I can't be more help. :(

Ken Puls, CMA
 
Thanks very much Ken. Your suggestion of multiple open documents worked.

I didn't quite have to import any other modules or anything else really.

I created a blank document and loaded my macro in it. Keeping this document open (one of the tabbed windows within the app) I now open an existing document. While working on the existing document, now when I go to the Macro menu I see the other document as a selection, and under that I see the macro. When I select to run that macro, sure enough it runs it on the existing document.

Maybe not exactly what you were suggesting, but you did give me the idea to try it that way.

So it effectively does the job. Good enough!

Thanks again!

-=K=-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top