How to add programmatically a vba macro to MS Outlook 2000?

Hi experts, I've created a macro and want to add it programmatically to MS Outlook.
How can this be performed?
It would be nice to get at least a link to an appropriate snippet.
Thank you for any help.
Who is Participating?
Whit3HawkConnect With a Mentor Commented:
OK. This is what I see:

When you create a procedure, by "inserting" it into a module in the VbaProject.OTM... any and all these procedures are stored in the C:\\windows\Profile\...\Application Data\Microsoft\Outlook.

If you want to make that file available to another stand alone computer, copy the file from that location onto the equivalent location in the computer you want to have access to the procedures in VbaProject.OTM.

When you open outlook in that machine, and do:

Tools-->Macro-->Visual Basic Editor, you will see the Project there.

To install that procedure, there are several ways, that I am able to determine. One is the calling of the procedure as in my previous comment/answer.

Another is by:

1.    Tools-->Customize

This opens a dialogue with a variety of commands and buttons.

2.   From the category window (left), choose "Macros." That will make visible all the procedures available in VbProject.OTM. (right)

3.   drag the procedure you want to intall onto the tool bar, and which point it will become a button on the tool bar. When the button is clicked, it will run that procedure.

If you don't see any procedures in the Command window, Start the Visual Basic Editor; you'll be promted to enable macros.

Then close it again, and repeat.1, 2, 3.

How/where did you create the macro?  Outlook 2000 and later use a file called VBAProject.otm to store all VBA code.  You can access this file by clicking ALT-F11 in Outlook.  That brings up the VBA editor.  

If that answer isn't what you're looking for, post some more detailed data on what you're trying to do.  For instance, did you create the macro in your Outlook 2000 and want to distribute it to others?
I've posted a similar question, meanwhile, looking for the answers I needed in the Outlook's Visual Basic Editor.

First, if you have created a macro using the outlook feature:

Tools-->Macros-->Visual Basic Editor

then you would have arrived at the VB Editor and the VBAProject.OTM will have been the ONLY project that you can store macros to use with Outlook.

Then, from inside the VB Editor, you would have had to do do:


That would have produced a dialog box to name the procedure you created, and once given a name, and saved, it would automatically be available to Outlook through the following Outlook action:

Tools--> Macro--> Macros

This would open a dialog box containing the name of the procedure you just created.

So, if you created the procedure correctly, as above, it would automatically become available to Outlook once it was saved in the VB Editor.

To run this Macro from inside Outlook, do

Tools--> Macro--> Macros
In the dialogue window that comes up, you'll see the procedure you created. You highligh it, and click the 'RUN' button.

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Darn! I don't know if I locked this question accidentally... 'cause I had no intention of keeping others from proposing other answers!!
HStrixAuthor Commented:
Thank you Whit3Hawk,
first of all I want to unlock (reject) your proposed answer to give others the opportunity to add comments.
Second I want to explain a little bit more my expectations:
Yes, I've created the macro inside Outlook's vba.
I'm using Outlook 2000.
The project explorer's window looks as follows:
- GiveInfo (VbaProject.OTM)
  - Microsoft Outlook Objects
    - ThisOutlookSession (contains "UserForm1.Show")
  - Forms
    - UserForm1
  - Modules
    - several module files
      getting computer name, user name,
      windows version etc.
My intension is that I want to setup an installation environment to add this entire code to Outlook of other users (on different computers). Therefore I want to have a(n easy) installation process; other users should have to do as little as possible.
If you want the installation to happen automatically,by running some installation program, outside of Outlook, then, you'll have to create a windows setup file, like any other installation setup pgm.

HStrixAuthor Commented:
Thank you  Whit3Hawk ,
your last comment meets exactly my intension.
I know how to create an installation file for VB6,
but I don't know the process how to do this for
my VBA macro. Which product can I use to do this?
I've never done this before.
Is there anything special I should be aware of?
I mean, how can I inform Outlook to recognize and accept that VBA macro automatically whithout further interaction?
Is there a way to do this?
When I need to do something, I use the tools I already know, trying to figure how! I don't know how to create an exe file with VB... or I forgot...

In your case, it would seem that the exe file would contain a simple process of copying the file into the appropriate outlook directory! (as in my earlier comment).

The previous steps (1 to 3) earlier comment, should be accomplished with VB code, or left to the user set up once the file is copied with a 'readme file telling him what to do, etc.

As for windows, I'd have to look for something equivalent to what in earlier versions they called "packaging"... which involved putting together all the programs and code to copy and set up info into a package which then became a 'setup' file. It was like writing a batch file, which then got converted to a setup exe in windows. I'm sure something similar is being done currently.

Hey, since you're the VB expert, I need some vb code to take email info from an email and put it in my contact list!

take care...

HStrixAuthor Commented:
Thank you Whit3Hawk,
I'll perform several tests and checks.
After this I'll post my results.
HStrixAuthor Commented:
Hey Whit3Hawk,
for your problem
you could have a look at the following link

thx, HStrix! I'd given up and ws already exporting email to spreadsheet. Would have worked to sort there, clean up and then reimport... but I'll give your sug. a shot!
HStrixAuthor Commented:
Hi Whit3Hawk,
in the meantime I've checked your suggestion.
Sorry that it took that long...
But now I can say: It worked perfectly!
Thank you again and I hope
that my suggestion has worked for you too.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.