Undefined Object: testing for Nothing (Redemption)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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...
 
In vbscript/vb6 the syntax is:

If Not (obj Is Nothing) Then

In VB.NET 8.0, it's:

If obj IsNot Nothing Then

--
Josh Einstein
Einstein Technologies
Microsoft Tablet PC MVP
Tablet Enhancements for Outlook 2.0 - Try it free for 14 days
www.tabletoutlook.com
 
..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
 
Thanks to both of you: what I needed.

Ken Slovak - said:
..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
 
Back
Top