Excel 2003 Macro

imported_cinder

Senior member
Sep 19, 2006
258
0
0
Can I create a macro that would allow me to create hyperlinks to every file in a single folder? I would have an individual link for every file.

I have a spread sheet I am working on for work and there must be over a thousand links that I need to create. If I can make a macro to take those files to create the links for me then it would be a HUGE time saver.

FYI, I am no expert at programing.

Thanks in advance for any help.
 

mayest

Senior member
Jun 30, 2006
306
0
0
This code should get you pretty close:

http://en.allexperts.com/q/Exc...A-Help-Create-List.htm

That will get you all of the Excel file names, but you'll need to get the entire path and create the hyperlink() function. Note, I'm pretty sure (99%) that the call to the Left function should be changed to Right instead, because you want to make sure that there is a slash on the right end of the directory name. I hesitate to say that for sure (100%) only because the code was provided by an Excel MVP. Still, they make mistakes just like the rest of us.
 

imported_cinder

Senior member
Sep 19, 2006
258
0
0
That is EXACTLY what I need but I still do not know how to add hyperlinks. Like I said I'm no expert programmer.

I also need to add links to word files too. Any tips would be greatly appreciated. In the mean time I will try to come up with the hyperlink code on my own but if you list it for me that would be fantastic.
 

imported_cinder

Senior member
Sep 19, 2006
258
0
0
I found the following code that does almost what I need. I need to add the hyperlinks that will take me to that file. Thanks in advnace for any help provided!!

Sub ListAllFiles()
Dim fs As FileSearch, ws As Worksheet, i As Long
Set fs = Application.FileSearch
With fs
.SearchSubFolders = False ' set to true if you want sub-folders included
.FileType = msoFileTypeAllFiles 'can modify to just Excel files eg with msoFileTypeExcelWorkbooks
.LookIn = "C:\" 'modify this to where you want to serach
If .Execute > 0 Then
Set ws = Worksheets.Add
For i = 1 To .FoundFiles.Count
ws. Cells(i, 1) = Mid$(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)
Next
Else
MsgBox "No files found"
End If
End With
End Sub
 

mayest

Senior member
Jun 30, 2006
306
0
0
To add the Hyperlink() function to a cell, replace the "ws.cells(..." line in the For loop with this:

ws.Cells(i, 1).Formula = "=hyperlink(" & Chr(34) & .FoundFiles(i) & Chr(34) & "," & Chr(34) & "Some Text" & Chr(34) & ")"

You will want to replace the "Some Text" with whatever text you want. For example, to show the file name use this:

ws.Cells(i, 1).Formula = "=hyperlink(" & Chr(34) & .FoundFiles(i) & Chr(34) & "," & Chr(34) & Mid$(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1) & Chr(34) & ")"

Note, though, that your code will not work in Excel 2007 due to changes in the object model.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |