Insert directory file names as hyperlinks

B

Bruce

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
 
A

Alex Dybenko

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

Bruce

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
 
D

Douglas J. Steele

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
 

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