PDA

View Full Version : Error handling declaring public variables



mrblack
03-27-2009, 02:29 PM
HI,
I was wondering if I could do some basic error handling before declaring any public variables. I have written some code to create Outlook appoinment items from Excel cell values. It starts off wth declaring the public variables:

Public myOlApp As Outlook.Application
Public myItem As Outlook.AppointmentItem

But to do this the system on which the script runs must have a reference to the Outlook 11.0 object library or the compiler will throw an error message like "User-defined datatype not defined".

Is there anyway to check (and alert the user) wether the library is referenced or not? Moreover, is it possible to reference the library run-time?

mdmackillop
03-27-2009, 04:14 PM
Have a look at this KB Item (http://www.vbaexpress.com/kb/getarticle.php?kb_id=267). Ignore the zip file (Corrupted)