Is there a way to create VBA that can be used in Outlook and Excel

I have created some VBA functions in Outlook to help with a process that involves both Excel and Outlook. Because of the commonality I want to be able to call the code from either Outlook or Excel, depending on what part of the process I am working on. The code includes a couple of custom forms and functions and because it is evolving I would rather not have to copy the code backwards and forwards each time it changes. Is there a way of including a common VBA module in both Outlook and Excel?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Sadly there is no good way to do what you want.  The best you can do is modularize the common code so that it's easy to copy between Excel and Outlook.  But short of writing your own COM object (tough stuff) there's no way to have shareable VBA code in a single location.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rob4077Author Commented:
I know there's a way to set a reference to a project in another Access database when you want to call a public procedure that's defined within a standard module in that database and I was hoping you could do the same here. If i convert my moduel into a ms access database is there a way to reference and use that?
John TsioumprisSoftware & Systems EngineerCommented:
If you skip the forms parts you could import all your functions to a VB6 ActiveX dll and use this from both your will take some work but i am sure that you can reach to a level that you will have a "universal" dll...also *untested* ...take a look at this interesting addon Also you could try for now to put the detection of Outlook/Excel in compiler directives but again is a case i haven't ever tried it
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.