Friday, November 6, 2009

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 & "*.Doc", vbNormal)
Do Until LenB(sDir) = 0
Set oWB = Documents.Open(sPath & sDir)
‘ Do some stuff
oWB.close
sDir = Dir$
Loop


The above will open all Word Documents under a particular directory.
Cheers,
Chithu

No comments: