title: Sql string with OLEDB gives error 1004 in VBA
body: <p>I would like to import a text file into excel filtering just what I want through a VBA macro. When I use LIKE operator in the sql string I get the error 1004.
  I have tried both <code>*</code> and <code>%</code> as wildcard and <code>ALike</code> instead of <code>Like</code> but there is no difference.</p>
  <p>test_7.txt</p>
  <pre><code>946737295   9CE78280    FF  1   5   FF  FF  FF  FF  FF
  946737295   9CE78280    C0  FF  0   0   0   0   FF  FF
  946737295   9CE68082    C0  4   0   FF  FF  FF  FF  FF
  </code></pre>
  <p>and the macro is:</p>
  <pre><code>Sub import_txt()
  
  Dim input_path As String
  input_path = &quot;C:\test_7.txt&quot;
  
  Dim strSql As Variant
  strSql = &quot;SELECT * FROM [test_7]&quot; &amp; _
     &quot; WHERE Column2 Like '*E7*' AND&quot; &amp; _
     &quot; Column4='FF'&quot;
     
      ActiveWorkbook.Queries.Add Name:=&quot;test_7&quot;, Formula:= _
      &quot;let&quot; &amp; &quot;    Origine = Csv.Document(File.Contents(&quot;&quot;&quot; &amp; input_path &amp; &quot;&quot;&quot;),[Delimiter=&quot;&quot;#(tab)&quot;&quot;, Columns=10, Encoding=1252, QuoteStyle=QuoteStyle.None]),&quot; &amp; &quot;    #&quot;&quot;Modifica tipo&quot;&quot; = Table.TransformColumnTypes(Origine,{{&quot;&quot;Column1&quot;&quot;, type text}, {&quot;&quot;Column2&quot;&quot;, type text}, {&quot;&quot;Colum&quot; &amp; _
      &quot;n3&quot;&quot;, type text}, {&quot;&quot;Column4&quot;&quot;, type text}, {&quot;&quot;Column5&quot;&quot;, type text}, {&quot;&quot;Column6&quot;&quot;, type text}, {&quot;&quot;Column7&quot;&quot;, type text}, {&quot;&quot;Column8&quot;&quot;, type text}, {&quot;&quot;Column9&quot;&quot;, type text}, {&quot;&quot;Column10&quot;&quot;, type text}})&quot; &amp; &quot;in&quot; &amp; &quot;    #&quot;&quot;Modifica tipo&quot;&quot;&quot;
      
  ActiveWorkbook.Worksheets.Add
  With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
      &quot;OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=test_7;Extended Properties=&quot;&quot;&quot;&quot;&quot; _
      , Destination:=Range(&quot;$A$1&quot;)).QueryTable
      .CommandType = xlCmdSql
      .CommandText = Array(strSql) 'Array(&quot;SELECT * FROM [test_7]&quot;)
      .RowNumbers = False
      .FillAdjacentFormulas = False
      .PreserveFormatting = True
      .RefreshOnFileOpen = False
      .BackgroundQuery = True
      .RefreshStyle = xlInsertDeleteCells
      .SavePassword = False
      .SaveData = True
      .AdjustColumnWidth = True
      .RefreshPeriod = 0
      .PreserveColumnInfo = True
      .ListObject.DisplayName = &quot;test_7&quot;
      .Refresh BackgroundQuery:=False
  End With
  End Sub
  </code></pre>