Insert directory file names as hyperlinks

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to add (import) the files in a directory as hyperlinks into my
database.

Say my target folder is c:\test
how can i get the name of the files and import these as a hyperlink in my DB.

One method
From DOS batch file i can rediret a folder contents to a .txt file and then
impotr the .txt file, however how would this same thing be done from VBA
alone?

Rgds,

Bruce
 
You can use Dir() function to enumerate file names, then add path to file
name - and now you can add this to table
 
Thanks Alex,

That got me started. The following finds the first file but how d I loop?
The Dir function is not a collection object. What do I do?

Bruce

Function getFiles()

'This
a = Dir("K:\Market\Forecast\*.xls")
MsgBox a

'Or This
ChDir ("K:\Market\Forecast\")
a = Dir("")
MsgBox a
End Function
 
While not a collection object, the Dir function does act as one. The
following will list all Excel files in your folder:

a = Dir("K:\Market\Forecast\*.xls")
Do While Len(a) > 0
MsgBox a
a = Dir()
Loop
 
Back
Top