Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2004
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Compile Error: Object required (OL2002/SP2)

    What does this error mean?
    (When I get it, the *** line is higlighted)



    Sub FindMostRecentMailing(strContact As String)

    Dim lItems As Long
    Dim NS As NameSpace
    Dim itmsJournal As Items
    Dim olTempItem As JournalItem
    Dim datMostRecent As Date

    Set NS = Application.GetNamespace("MAPI")
    Set itmsJournal = NS.GetDefaultFolder(olFolderJournal).Items


    ' Loop through journal folder items
    For lItems = itmsJournal.Count To 1 Step -1
    Set olTempItem = itmsJournal(lItems)
    ' Check to see if a match is found
    If InStr(1, olTempItem.Type, "Mailed", 0) > 0 Then
    If InStr(1, olTempItem.Subject, strContact, 0) > 0 Then
    If datMostRecent <> "" Then
    If DateDiff("d", olTempItem.Start, datMostRecent) < 0 Then
    *** Set datMostRecent = olTempItem.Start
    End If
    Set datMostRecent = olTempItem.Start
    End If
    End If
    End If
    Next

    MsgBox strContact & " :: " & datMostRecent

    ' empty objects
    Set datMostRecent = Nothing
    Set itmsJournal = Nothing
    Set NS = Nothing


    End Sub

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Compile Error: Object required (OL2002/SP2)

    You don't need to use "Set" for this assignment. Set needs to be used for Objects and Collections and a few other things, but in this case

    datMostRecent = olTempItem.Start

    should do it. (And because it's not an Object, you don't need to empty it when the routine closes.)
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    New Lounger
    Join Date
    Feb 2004
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error: Object required (OL2002/SP2)

    A belated thanks John. As usual, your posts eventually teach me something (once I am able to absorb them) . [img]/forums/images/smilies/ohmy.gif[/img])

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •