• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1331
  • Last Modified:

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"
0
newparadigmz
Asked:
newparadigmz
1 Solution
 
Farzad AkbarnejadCommented:
Change

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

to

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

-FA
0
 
newparadigmzAuthor Commented:
perfect!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now