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
 
Yes, that pesky Not definitely needs to be there! Good catch.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top