Consulting

Results 1 to 2 of 2

Thread: Error handling declaring public variables

  1. #1
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    5
    Location

    Error handling declaring public variables

    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?

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Have a look at this KB Item. Ignore the zip file (Corrupted)
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •