How can i create a List of Files ?

C

Costis

Hello,

i would like to create a representation of the existing files per directory,
so that i can follow up the files i am keeping in the various data
directories i have (not the system).
I Know this information already exists in the system, and it is utilized by
Windows Explorer but i do not know how to access it and import it in Visio,
possibly via Excell or Access.

Any Help?
Thanks in advance
 
J

JuneTheSecond

This is my example.
Please, include Excel object library in your project.
Sub MakeFileList()
Dim fs As FileSearch
Dim I As Long, N As Long
Set fs = Excel.Application.FileSearch
With fs
.LookIn = "D:\Documents and Settings\Administrator\My Documents"
.FileName = "*.vsd"
If .Execute(SortBy:=msoSortByFileName,
SortOrder:=msoSortOrderAscending) > 0 Then
N = .FoundFiles.Count
MsgBox N & " files are found."
For I = 1 To N
Debug.Print .FoundFiles(I)
Next I
Else
MsgBox "No files found for condition."
End If
End With
End Sub
 
C

Costis

Thank you, i shall try it!

JuneTheSecond said:
This is my example.
Please, include Excel object library in your project.
Sub MakeFileList()
Dim fs As FileSearch
Dim I As Long, N As Long
Set fs = Excel.Application.FileSearch
With fs
.LookIn = "D:\Documents and Settings\Administrator\My Documents"
.FileName = "*.vsd"
If .Execute(SortBy:=msoSortByFileName,
SortOrder:=msoSortOrderAscending) > 0 Then
N = .FoundFiles.Count
MsgBox N & " files are found."
For I = 1 To N
Debug.Print .FoundFiles(I)
Next I
Else
MsgBox "No files found for condition."
End If
End With
End Sub
 
J

JuneTheSecond

I am sorry. Please replace it to next code.
Sub MakeFileList()
Dim fs As FileSearch
Dim I As Integer

Set fs = excel.Application.FileSearch
fs.RefreshScopes
With fs
.NewSearch
.LookIn = "C:\Documents and Settings\yoda\My Documents"
.FileType = msoFileTypeVisioFiles
' .FileName = "*.vsd"

If .Execute > 0 Then
MsgBox .FoundFiles.Count & " files are found."
For I = 1 To .FoundFiles.Count
Debug.Print .FoundFiles(I)
Next I
Else
MsgBox "File not found."

End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top