title: VBA throws an error when a string is changed to a variable with exact string
body: <p>This is my vba code for powerquery function</p>
  <pre><code>ActiveWorkbook.Queries.Add Name:=&quot;Or ORder&quot;, Formula:= _
          &quot;let&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &amp; &quot;    Source = Excel.Workbook(File.Contents(&quot;&quot;C:\Users\DDK\Downloads\excel.xlsx&quot;&quot;), null, true),&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &amp; &quot;    Sheet1_Sheet = Source{[Item=&quot;&quot;Sheet1&quot;&quot;,Kind=&quot;&quot;Sheet&quot;&quot;]}[Data],&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &amp; &quot;    #&quot;&quot;Promoted Headers&quot;&quot; = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &amp; &quot;    #&quot;&quot;Changed Type&quot;&quot; = Table.TransformColumnTypes(#&quot;&quot;Promoted Headers&quot;&quot;,{{&quot;&quot;Column1&quot;&quot;, type any}&quot; &amp; _
          &quot;, {&quot;&quot;CROWN&quot;&quot;, type any}, {&quot;&quot;March 15th, 2021&quot;&quot;, type text}, {&quot;&quot;Column4&quot;&quot;, type any}, {&quot;&quot;Column5&quot;&quot;, type any}}),&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &amp; &quot;    #&quot;&quot;Removed Top Rows&quot;&quot; = Table.Skip(#&quot;&quot;Changed Type&quot;&quot;,2),&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &amp; &quot;    #&quot;&quot;Renamed Columns&quot;&quot; = Table.RenameColumns(#&quot;&quot;Removed Top Rows&quot;&quot;,{{&quot;&quot;Column1&quot;&quot;, &quot;&quot;QTY&quot;&quot;}, {&quot;&quot;CROWN&quot;&quot;, &quot;&quot;ITEM&quot;&quot;}, {&quot;&quot;March 15th, 2021&quot;&quot;, &quot;&quot;Part&quot;&quot;}, {&quot;&quot;Column5&quot;&quot;, &quot;&quot;Price&quot;&quot;}}),&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &amp; &quot;    #&quot;&quot;Filter&quot; &amp; _
          &quot;ed Rows&quot;&quot; = Table.SelectRows(#&quot;&quot;Renamed Columns&quot;&quot;, each [QTY] &lt;&gt; null and [QTY] &lt;&gt; &quot;&quot;&quot;&quot;)&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &amp; &quot;in&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &amp; &quot;    #&quot;&quot;Filtered Rows&quot;&quot;&quot;
      ActiveWorkbook.Worksheets.Add.Name = &quot;Our Order&quot;
      With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
          &quot;OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=&quot;&quot;Or ORder&quot;&quot;;Extended Properties=&quot;&quot;&quot;&quot;&quot; _
          , Destination:=Range(&quot;$A$1&quot;)).QueryTable
          .CommandType = xlCmdSql
          .CommandText = Array(&quot;SELECT * FROM [Or ORder]&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;Or_ORder&quot;
          .Refresh BackgroundQuery:=False
      End With
  </code></pre>
  <p>When the file directory for the source is changed to a variable like this</p>
  <pre><code>Dim fileOrder as String
  fileOrder = &quot;C:\Users\Ddk\Downloads\excel.xlsx&quot;
  ....
  Source = Excel.Workbook(File.Contents(fileOrder), null, true),&quot; &amp; Chr(13) &amp; &quot;&quot; &amp; Chr(10) &quot;&quot;....
      
  </code></pre>
  <p>It throws an error when it reaches <code>.Refresh BackgroundQuery:=False</code>. Why is it? Even when it is the exact same string it gives an error <code>[Expression.Error] The import Order matches no exports. Did you miss a module reference?</code></p>
  <p>The thing is I want user to select the excel file for power query through VBA that's why I need to have a variable on file directory.</p>