Error 91

  • Thread starter Thread starter Raymond
  • Start date Start date
R

Raymond

Hi

i,ve created this code but i'm getting error 91 on this line
Set outMailItem = Application.ActiveInspector.CurrentItem


Sub Mailitem_Open()
Dim outMailItem As MailItem
Set outMailItem = Application.ActiveInspector.CurrentItem
Dim test
If outMailItem.UnRead = False Then
myMsg = "Do you want to open this message again?"
If MsgBox(myMsg, 4) = 6 Then
test = True
'MsgBox test
UserForm1.Show
Else
test = False
MsgBox test
End If
End If
End Sub


can anyone tell why and how i can solve this problem
 
Do you actually have an Inspector window open? Is it showing a message? Best
practice is not to assume that you know the type of item:

Dim outMailItem As Object
On Error Resume Next
Set outMailItem = Application.ActiveInspector.CurrentItem
If Not outMail Item Is Nothing Then
If outMailItem.Class = olMail Then
If outMailItem.UnRead = False Then
myMsg = "Do you want to open this message again?"

etc.
 
Back
Top