Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding a directory

Status
Not open for further replies.

Kori

Programmer
Oct 17, 2000
35
0
0
US
I am trying to find code that will take a file name such as "netscape.exe" and pass back the directory it is located in. Any ideas?
 


Hi Kori


This is just something ive seen in my travels through the help files and i have never used it - but it did look useful.

With Application.FileSearch
.NewSearch
.LookIn = "C:\MyDocuments"
.SearchSubFolders = True
.FileName = "MyFile.txt"
.MatchAllWordForms = True
.Execute
MsgBox .FoundFiles(1)

End With

However, saying that, I would have thought that there must be a more efficient way. Out of my depth here, but I would imagine that you can access the registery and get the information from there much easier- just dont ask me how!!

Good luck.


Stew
 
Man u should that wonderful thing that MS calls FileSystemObject - it's in a weird library whose name I never understood - VBScript or something containing 'script'

Good Luck !
 
You need to add a reference to the scripting runtime or something like that

then you can create a file object and get it's directory

Transcend
[gorgeous]
 
scrrun.dll

Mark

The key to immortality is to make a big impression in this life!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top