title: Run-time error 1004 on .Refresh BackgroundQuery:=False VBA
body: <p>Good morning, that's my first post here ...so please be patient with me :)</p>
  
  <p>I've a problem with a VBA code I'm trying to execute on Excel 2016. I'm running a MacOSX Sierra machine.</p>
  
  <p>Everyday I need to import data from 3 .csv files and put it on 3 different excel worksheets, format data in a particular way and add a weblink, so I recorded a macro on an excel file which does this for me.</p>
  
  <p>Here is the code to import a single .csv (that's the same for all ones)</p>
  
  <pre><code>Sub csvimport()
  '
  ' csvimport Macro
  '
  ' Keyboard Shortcut: Option+Cmd+Shift+I
  '
      Sheets("displayAddedByCollaboration").Select
      Columns("A:A").Select
      With ActiveSheet.QueryTables.Add(Connection:= _
          "TEXT;/Users/oem/Desktop/report/displayAddedByCollaborationReport.csv", _
          Destination:=Range("A1"))
          .Name = "displayAddedByCollaborationReport"
          .FieldNames = True
          .RowNumbers = False
          .FillAdjacentFormulas = False
          .RefreshOnFileOpen = False
          .BackgroundQuery = True
          .RefreshStyle = xlInsertDeleteCells
          .SavePassword = False
          .SaveData = True
          .AdjustColumnWidth = True
          .TextFilePromptOnRefresh = False
          .TextFilePlatform = xlMacintosh
          .TextFileStartRow = 1
          .TextFileParseType = xlDelimited
          .TextFileTextQualifier = xlTextQualifierDoubleQuote
          .TextFileConsecutiveDelimiter = False
          .TextFileTabDelimiter = True
          .TextFileSemicolonDelimiter = False
          .TextFileCommaDelimiter = False
          .TextFileSpaceDelimiter = False
          .TextFileColumnDataTypes = Array(1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1)
          .Refresh BackgroundQuery:=False
          .UseListObject = False
      End With
      ActiveWindow.ScrollColumn = 16
      Range("U2").Select
      ActiveCell.FormulaR1C1 = _
          "=IF(RC[-3] = """","""",HYPERLINK(""https://www.google.it/"",""View receipt""))"
      Range("U2").Select
      Selection.AutoFill Destination:=Range("U2:U2001"), Type:=xlFillDefault
      Range("U2:U2001").Select
      ActiveWindow.ScrollRow = 1
      ActiveWindow.ScrollColumn = 1
      Cells.Select
      Selection.AutoFilter
      ActiveWorkbook.Worksheets("displayAddedByCollaboration").AutoFilter.Sort. _
          SortFields.Clear
      ActiveWorkbook.Worksheets("displayAddedByCollaboration").AutoFilter.Sort. _
          SortFields.Add Key:=Range("A1:A2001"), SortOn:=xlSortOnValues, Order:= _
          xlDescending, DataOption:=xlSortNormal
      With ActiveWorkbook.Worksheets("displayAddedByCollaboration").AutoFilter.Sort
          .Header = xlYes
          .MatchCase = False
          .Orientation = xlTopToBottom
          .SortMethod = xlPinYin
          .Apply
      End With
  End Sub
  </code></pre>
  
  <p>It works fine for a couple of days and than, unexpectedly, it stops working returning a Run-time error 1004. The code stops at this line and I can't figure out why:</p>
  
  <pre><code>.Refresh BackgroundQuery:=False
  </code></pre>
  
  <p>That's the content of report folder on my desktop:</p>
  
  <pre><code>Mauros-MacBook-Pro-2:~ oem$ cd /Users/oem/Desktop/report/
  Mauros-MacBook-Pro-2:report oem$ ls -la
  total 2592
  drwx------@  6 oem  staff      204 May  5 08:35 .
  drwx------+ 12 oem  staff      408 May  5 09:53 ..
  -rw-r--r--@  1 oem  staff     6148 May  5 08:35 .DS_Store
  -rwxr-xr-x@  1 oem  staff    46795 May  5 08:32 displayAddedByCollaborationReport.csv
  -rwxr-xr-x@  1 oem  staff    55837 May  5 08:32 eanNotInAnagraphic.csv
  -rwxr-xr-x@  1 oem  staff  1210072 May  5 08:32 notCertifiedProductRecognizedReport.csv
  </code></pre>
  
  <p>Any suggestion would be appreciated.
  Thank you!</p>