Excel VBA "Cannot Parse Condition." error message

I am running a VBA script that reads emails subject lines in my Outlook Inbox and copies attachments in the emails to a folder. The subject lines are stored on a worksheet. It works except when the subject line contains a ":". Below is the error message I get, the offending code, and the subject that it's breaking on.

Run-time error
Cannot Parse Condition. Error at ":".

    For i = 1 To UBound(avTable)
        strFilter = "[Subject] = " & avTable(i, 1)
        For Each itm In avTodayItems.Restrict(strFilter)            
             For Each att In itm.Attachments
                strFilename = LCase(att.Filename)
                If LCase(strFilename) = LCase(avTable(i, 2)) Then
                    att.SaveAsFile [nmFolder] & avTable(i, 3)
                End If
            Next att
        Next itm
    Next i

strFilter = "[Subject] = File 15.08.2012: Daily"
newparadigmzAsked:
Who is Participating?
 
Farzad AkbarnejadConnect With a Mentor DeveloperCommented:
Change

strFilter = "[Subject] = " & avTable(i, 1)

to

strFilter = "[Subject] = " & Chr(34) & avTable(i, 1) & Chr(34)

-FA
0
 
newparadigmzAuthor Commented:
perfect!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.