A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Undefined Object: testing for Nothing (Redemption)



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 20th 06, 11:33 AM posted to microsoft.public.outlook.program_vba
Martin
external usenet poster
 
Posts: 87
Default Undefined Object: testing for Nothing (Redemption)

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
  #2  
Old January 20th 06, 03:30 PM posted to microsoft.public.outlook.program_vba
Josh Einstein
external usenet poster
 
Posts: 57
Default Undefined Object: testing for Nothing (Redemption)

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


"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...



  #3  
Old January 20th 06, 03:33 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
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...


  #4  
Old January 25th 06, 09:21 AM posted to microsoft.public.outlook.program_vba
Martin
external usenet poster
 
Posts: 87
Default Undefined Object: testing for Nothing (Redemption)

Thanks to both of you: what I needed.

"Ken Slovak - [MVP - Outlook]" wrote:

..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...



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redemption Christoph Add-ins for Outlook 5 March 6th 06 03:26 PM
News server name for software testing -reg thirumalai Outlook - General Queries 1 February 12th 06 09:12 AM
Testing my first Email jratkins Outlook Express 1 February 11th 06 02:15 PM
Testing William Brady Outlook - General Queries 0 February 3rd 06 05:31 PM
Redemption MAPITable Dmitry Streblechenko Add-ins for Outlook 1 January 12th 06 04:09 AM


All times are GMT +1. The time now is 10:26 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.