MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Inserting All files from directory


Posted by Troy on August 09, 2001 7:26 AM

I am looking for help with a loop that would insert a jpeg from a directory and the go back and insert the next jpeg from the directory until they are all inserted. The file names are not if any particular order, but want to add each item. Thanlks.


Posted by Damon Ostrander on August 09, 2001 8:45 PM

Troy,

Check out the VBA Dir function. Call it once with arguments to tell it what folder to look in and the file spec. Then all subsequent calls without arguments will return other files in that folder that meet the file spec with wildcards, etc. You can easily loop through all the .jpg files in a folder using this function. There is a pretty good example of its use in the VBA helps.

Damon