Excel VBA "Cannot Parse Condition." error message

Posted on 2012-08-17
Last Modified: 2012-08-17
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"
Question by:newparadigmz
    LVL 14

    Accepted Solution


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


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


    Author Closing Comment


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
    This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
    The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now