Reading through files in a folder

by Linda Quinn

Close Window

This code allows the user to read through a folder and process the files that match the criteria.
The dir command will read through the folder given as a parameter.
You can also specify a file extension, a file name or a wildcard in order to restrict which files in the folder are selected.


Dim mfile as String
Dim wkb as Excel.Workbook

mfile = Dir(c:\folder1\ + "JV1*.xls")
Do While mfile <> ""
Set wkb = Workbooks.Open FileName:=mfile
Call processJV1
wkb.Close SaveChanges:=False
mfile = Dir
Loop

MsgBox "Processing is complete "








=================================================================
This content was created by Linda Quinn of LQNet.

See http://www.lqnet.com for a great collection of articles on this and other topics.

=================================================================
Copyright © 2006-2008, LQ Systems,Inc. All rights reserved.


====================================================================
Want an expert to help with your project?    LQ Systems, Inc.   Business Solutions
====================================================================