Dir or Dir$ Function can be used in Microsoft Visual Basic (Applications) to get the list of directories or files
sDir = Dir$(sPath & "*.xls", vbNormal)
Do Until LenB(sDir) = 0
Set oWB = Workbooks.Open(sPath & sDir)
‘ Do some stuff
oWB.close
sDir = Dir$
Loop
The above will open all Excel Workbooks under a particular directory.
Thursday, December 14, 2006
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.
thanks. this code works great!
ReplyDeleteWith subfolders?
ReplyDeleteExcellent example. For Word, just use "Document.Open" instead of "Workbooks.Open". Thanks!
ReplyDeleteWhat is Dir$ and sPath?
ReplyDelete