HANDLING ERRORS USING FIND

  • Thread starter chuck.grob@invesco.com
  • Start date
Status
Not open for further replies.
C

chuck.grob@invesco.com

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
 
S

Sue Mosher [MVP]

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

Sue Mosher

<chuck.grob@invesco.com> wrote in message

news:801888e3-d5f6-4e55-96d4-2a1f13274593@w9g2000yqa.googlegroups.com...
> 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
>
 
C

chuck.grob@invesco.com

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
 
S

Sue Mosher [MVP]

Yes, that pesky Not definitely needs to be there! Good catch.

Sue Mosher

<chuck.grob@invesco.com> wrote in message

news:2553f5a9-39cc-422a-aa2d-9f951c948caf@e18g2000yqo.googlegroups.com...
> 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

>
 
Status
Not open for further replies.
Top