Showing posts with label open all Excel Workbooks under a particular directory. Show all posts
Showing posts with label open all Excel Workbooks under a particular directory. Show all posts

Thursday, December 14, 2006

Dir Function in VBA (Visual Basic)

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.
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.