View Full Version : Get all files and folders in diretory
msretenovic
2004-09-17, 02:51 PM
In VBA, I need to get a list of all files in a directory as well as a list of folders. :???: I don't know how to get this in VBA and would appreciate any help that I could get.:-) I want to be able to store these in two seperate variables as well.
AutoCAD 2004
Win 2000
Thanks,
msretenovic
2004-09-17, 04:04 PM
Nevermind, I found what I was needing. I got this to get the list of folders:
i = 0
strTmp = Dir(strDir, vbDirectory)
Do While strTmp <> ""
If strTmp <> "." And strTmp <> ".." Then
If (GetAttr(strDir & strTmp) And vbDirectory) = vbDirectory Then
ReDim Preserve strDirs(i)
strDirs(i) = strDir & strTmp & "\"
i = i + 1
End If
End If
strTmp = Dir
Loop
and this to get the files:
i = 0
strTmp = Dir(strDir, vbNormal)
Do While strTmp <> ""
If (strTmp <> ".") And (strTmp <> "..") And (Mid(strTmp, (Len(strTmp) - 3)) = ".dwg") Then
If (GetAttr(strDir & strTmp) And vbNormal) = vbNormal Then
ReDim Preserve strFiles(i)
strFiles(i) = strTmp
i = i + 1
End If
End If
strTmp = Dir
Loop
I was overlooking the Dir function :razz:
chill3490
2004-09-27, 01:57 PM
Hi Michael,
How are you employing VBA at your company?
The reason I ask: I am just learning VBA and would like to employ it in setting up a mini-document mgmt system using both MS Access 97 and AutoCAD 2004 and would like to bounce ideas off people doing roughly the same thing...i.e. using VBA to extract dwg info from block attributes , semi-automatic xfer and/or updating of data between app's, etc.
Interested?
Regards,
Clint Hill
Designer
Win XP Pro
AcadMech2k4
msretenovic
2004-09-27, 03:03 PM
Clint,
Actually, I'm just now starting to use VBA here. I've been using LISP up 'til now. As we upgrade to 2005, I plan on using more VBA though.
As for creating a mini-doc manager, I never really gave it too much thought. But, I think once I get used to using VBA, I may give it more thought later. One of the things that I would really like to do is get area information from our base plan drawings and put it on the cover sheet. Although I haven't had time to do this yet, I think that doing this with VBA would be a great learning experience for me. :smile:
Ed Jobe
2004-09-27, 03:11 PM
Clint,
I was going to bounce back, but this thread is on a different subject. Perhaps you should start a new thread for your purpose.
chill3490
2004-09-27, 03:33 PM
Ed J.,
Great idea, Pizzameister! Here it goes.....
Clint Munster
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.