Ok the code is actually from Access...

The line that is causing the problem is the attempt to GetObject if outlook is not open then this will cause a problem.

If the code is inside Outlook you should be able to drop the outlook part of it... like so

VB Code:
  1. Dim myOlExp As Explorers
  2.   Dim obSi As Selection
  3.   Dim obMi As MailItem
  4.   Set myOlExp = Application.Explorers
  5.   Set obSi = myOlExp.Item(1).Selection
  6.   For i = 1 To obSi.Count
  7.     Set obMi = obSi.Item(i)
  8.     Debug.Print obMi.SenderName
  9.     Debug.Print obMi.Subject
  10.   Next i
  11.   Set obMi = Nothing
  12.   Set obSi = Nothing
  13.   Set myOlExp = Nothing

In my corporation VBA is disabled behind Outlook so I cannot test to see if this will actually work