HANDLING ERRORS USING FIND

  • Thread starter Thread starter chuck.grob
  • Start date Start date
C

chuck.grob

The code below is what I am using to handle a very unusual situation
(VBA code cannot find an email with 'specific email Subject' as the
Subject).

Is there a better way to do this?

Set olMi = Fldr.Items.Find("[Subject] = 'specific email Subject")

If Not TypeName(olMi) = "Nothing" Then
olMi.Delete
End If

Thanks for your input,
JingleRock
 
I'd use something more like this:

On Error Resume Next
Set olMi = Fldr.Items.Find("[Subject] = 'specific email Subject")
If olMi Is Nothing Then
olMi.Delete
End If
 
Thanks Sue,

I think you meant:

I'd use something more like this:

If Not olMi Is Nothing Then
olMi.Delete
End If

If code finds email (it almost always will), then it will be deleted.

JingleRock
 
Back
Top