Excel to Outlook VBA Library References

backfromthebush

New Member
Joined
Jul 2, 2010
Messages
37
Hi all,

I have an Excel spreadsheet which has an option to send certain data from it via an email in Outlook simply by clicking a user form button.

I have set the Library Reference to "Microsoft Outlook 15.0" and tested the code and all works OK. I have three questions though:-
1. If I send this Excel file to other users, will the Object Reference remain, or will they need to go into the VBA module and re-select it?
2. Is there an easy way to automatically select this Object Reference using VBA code?
3. If one of the spreadsheet users does not have access to Outlook (yes we have a few of these!!), is there a way to include some code that would exit the procedure (and maybe with a pop up message advising that Outlook isn't available?
I also tested the code to run without the Outlook 15.0 selected, and tried to put an error handler in. I received a Compile Error: user defined type not defined (from the code: dim olApp As New Outlook.Application) - so I assume you can't put an error handler on errors occuring when declaring variables??

Thanks in advance!!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,

It sounds like you need to convert your code from "Early Binding" to "Late Binding".

In simple terms, Early Binding is when you write in your procedure at work: Go and see Joe in the office and he will give you the correct form etc etc.
Late Binding is when the procedure says: Go to the office and ask who can help you with ... etc.

In the first case you have a contact and that lets you know his place of work, work schedule, phone number, name etc. With Late Binding you only find that out when you are actually following the procedure. That may be some time after the procedure was written - hence "Late".

Early Binding runs slightly quicker and can do more checking. Late Binding works when you give the procedure to someone in a remote place of work and Joe is not their best contact. Someone local should be used instead. So Late Binding is slower but more widely applicable.

If you have code like this:
Code:
Sub Accounts()
    Dim olApp   As Outlook.Application
    Dim olNS    As Outlook.Namespace
    Dim olAcc   As Outlook.Account
    Dim olFldr  As Outlook.MAPIFolder
It implies that you are using Early Binding and the Reference needs to be set because at compile time the procedure will check on all those Outlook references.
You can convert those objects to just plain "Objects" - NB other changes may be needed depending upon how the code was written - and you should have some code that will work for anyone (with Outlook).

Perhaps if you post your code someone could make the changes for you.

Regards,
 
Upvote 0

Forum statistics

Threads
1,215,454
Messages
6,124,931
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top