View Single Post
  #3  
Old January 20th 06, 03:33 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,426
Default Undefined Object: testing for Nothing (Redemption)

..Sender is an AddressEntry object so it's Nothing if not instantiated.

Use this:

If (Not (SafeItem.Sender Is Nothing)) Then
'ok to use
Else
'some error handling
End If

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Martin" wrote in message
...
This is really a general VBA problem but it's come up in Outlook so I
thought
I'd post it here. Is there any way of testing for an empty property, i.e.
one that's been set to Nothing? I've tried all the functions like
IsEmpty,
IsNull, IsMissing, etc but I've ended up having to settle for a rather
clumsy
error routine that catches error 91.

The particular case in which I'm having problems is using Redemption: in
the
CurrentItem_PropertyChange event (for ThisOutlookSession module) I've set
the
SafeItem equal to the CurrentItem but for some reason the
SentOnBehalfOfName
doesn't come across, even though I've preceded this line with a
CurrentItem.Save (the strange thing about this is that it worked fine when
run in the CurrentItem_Send event - I guess it's something to do with
trying
to save an entire message before one of its properties has been updated).
As
a work around, I'm using SafeItem.Sender.Name (a property I spotted in the
Locals window while stepping through the code). This works fine unless
the
From box is empty in which case SafeItem.Sender.Name ceases to exist at
all
and SafeItem.Sender becomes Nothing - rather than a Null or an empty
string
which could be more easily tested for.

Any ideas gratefully received...


Ads
 

Personal Loans - Car Credit - Final Fantasy Soundtracks - Mobile Phone - Car Insurance