Syntax for looping through all xl files in a folder

S

ShaneDevenshire

Hi Folks,

On the PC if you want to increment through all the Excel files in a folder
you would use something like:

myFile = Dir("C:\Data\*.xls")
Do Until myFile = ""
...
myFile = Dir
Loop

What is the equivalent code on the Mac?

TIA,
Shane Devenshire
 
J

JE McGimpsey

ShaneDevenshire said:
Hi Folks,

On the PC if you want to increment through all the Excel files in a folder
you would use something like:

myFile = Dir("C:\Data\*.xls")
Do Until myFile = ""
...
myFile = Dir
Loop

What is the equivalent code on the Mac?

MacXL/VBA Help has a pretty good description of Dir() and the
differences between Mac and WinXL.

Essentially, you change

myFile = Dir("C:\Data\*.xls")

To

myFile = Dir(<path>, MacID("XLS8"))

Make sure the <path> ends with the path separator :)).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top