title: How to loop through files in a folder Excel Mac 2016
body: <p>I'm trying to combine several excel files into one. For this I've been using and modifying an old answer I <a href="https://stackoverflow.com/questions/11963284/applescript-to-combine-multiple-excel-files-into-a-single-worksheet/11975711#11975711">found here</a>, but I ran into trouble while running it on Excel 2016 for Mac (it worked ok with Excel 2011 for Mac, with some changes).</p>
  
  <p>In Excel 2016 (Mac), the following code runs through the loop once, after which it prints the name of the first file in the selected folder, but then it stops.</p>
  
  <p>In Excel 2011 (Mac), it correctly prints the names of all files in the selected folder. </p>
  
  <pre><code>Sub wat()
  Dim FilesFolder As String, strFile As String
  
  'mac excel 2011
  'FilesFolder = MacScript("(choose folder with prompt ""dis"") as string")
  
  'mac excel 2016
  FilesFolder = MacScript("return posix path of (choose folder with prompt ""dat"") as string")
  
  If FilesFolder = "" Then Exit Sub
  
  strFile = Dir(FilesFolder)
  
  Do While Len(strFile) &gt; 0
  
      Debug.Print "1. " &amp; strFile
  
      strFile = Dir
  
  Loop
  
  MsgBox "ded"
  End Sub
  </code></pre>
  
  <p>So, I'm pretty new at this, but it looks to me like <code>strFile = Dir</code> is not working properly. </p>
  
  <p>I looked at the Ron deBruin page:
  <a href="http://www.rondebruin.nl/mac/mac013.htm" rel="nofollow noreferrer">Loop through Files in Folder on a Mac (Dir for Mac Excel)</a>
  but to be honest that was a little too complicated for me to comprehend and modify to my needs.  </p>
  
  <p>Any help is appreciated, and thanks for the patience!</p>