MikeD
MikeD

Reputation: 8941

reuse VB(A) code across multiple Office applications

We are using different Office applications (Excel, Word, Powerpoint, Access, Visio) in versions between 2003 and 2010. I have a simple task which is the same in each of these application, namely creating a filename based on a couple of parameters to pick from a dialog box.

Sofar I have created a Function getStructuredFilename() as String displaying a (modal) form with some buttons and text boxes, returning a string, for each individual Office application in its own VBA environment and stored them in template files used with each of these applications - meaning I have to maintain the same piece of code for each of the Office applications seperately.

This brings with it that (eg. Excel) all files created on the basis of that template do "contain macro's" which some of my users find disturbing.

I wonder if there is a way of defining the dialog form once and call it from each of the office applications - like an "external reference", an ActiveX, whatever ...

Any ideas?

Upvotes: 1

Views: 384

Answers (1)

Zaider
Zaider

Reputation: 2013

From within the VBA editor you can export your module as a .bas file which will allow you to import your completed code without having to redo it every time.

Alternatively have you looked into creating a plugin for office? These may be of use to you. http://msdn.microsoft.com/en-us/library/office/aa166223%28v=office.10%29.aspx http://msdn.microsoft.com/en-us/magazine/cc507643.aspx

Upvotes: 3

Related Questions