Link to home
Start Free TrialLog in
Avatar of HStrix
HStrix

asked on

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.
HStrix
Avatar of rjcpjc
rjcpjc

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:

Insert-->Procedure

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.






Darn! I don't know if I locked this question accidentally... 'cause I had no intention of keeping others from proposing other answers!!
Avatar of HStrix

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Whit3Hawk
Whit3Hawk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.

Avatar of HStrix

ASKER

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...





Avatar of HStrix

ASKER

Thank you Whit3Hawk,
I'll perform several tests and checks.
After this I'll post my results.
Avatar of HStrix

ASKER

Hey Whit3Hawk,
for your problem
you could have a look at the following link
---
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=5724&lngWId=1
---


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!
Avatar of HStrix

ASKER

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.
HStrix