#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default hyperlink to files

Assuming it's possible, could someone help me with the macro code to get all
the file names, regardless of type, within a specific folder and then list
those names including as much as possible of the file path in a column of the
sheet that I execute the macro from?

If the macro can pull the info in as a hyperlink that would be a bonus but I
can work that separately if needed.

I need this to be something that I can assign to a button so that the user
can update the list prior to each use.
--
THANKS!

Steve
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default hyperlink to files

Steve,

Change the .LookIn path as needed.... The list will start in the activecell

Sub FindFilesAndHyperlink2Them()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Foler"
'.SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).Value = .FoundFiles(i)
ActiveCell.Cells(i, 2).FormulaR1C1 = "=HYPERLINK(RC[-1])"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub



HTH,
Bernie
MS Excel MVP


"Steve_n_KC" wrote in message
...
Assuming it's possible, could someone help me with the macro code to get all
the file names, regardless of type, within a specific folder and then list
those names including as much as possible of the file path in a column of the
sheet that I execute the macro from?

If the macro can pull the info in as a hyperlink that would be a bonus but I
can work that separately if needed.

I need this to be something that I can assign to a button so that the user
can update the list prior to each use.
--
THANKS!

Steve



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default hyperlink to files

And if you just want the hyperlink:

Sub FindFilesAndHyperlink2ThemV2()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Folder"
' .SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).FormulaR1C1 = "=HYPERLINK(""" & .FoundFiles(i) & """)"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub


--
HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Steve,

Change the .LookIn path as needed.... The list will start in the activecell

Sub FindFilesAndHyperlink2Them()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Foler"
'.SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).Value = .FoundFiles(i)
ActiveCell.Cells(i, 2).FormulaR1C1 = "=HYPERLINK(RC[-1])"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub



HTH,
Bernie
MS Excel MVP


"Steve_n_KC" wrote in message
...
Assuming it's possible, could someone help me with the macro code to get all
the file names, regardless of type, within a specific folder and then list
those names including as much as possible of the file path in a column of the
sheet that I execute the macro from?

If the macro can pull the info in as a hyperlink that would be a bonus but I
can work that separately if needed.

I need this to be something that I can assign to a button so that the user
can update the list prior to each use.
--
THANKS!

Steve





  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default hyperlink to files

PERFECT! Thanks So Much!
--
THANKS!

Steve


"Bernie Deitrick" wrote:

Steve,

Change the .LookIn path as needed.... The list will start in the activecell

Sub FindFilesAndHyperlink2Them()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Foler"
'.SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).Value = .FoundFiles(i)
ActiveCell.Cells(i, 2).FormulaR1C1 = "=HYPERLINK(RC[-1])"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub



HTH,
Bernie
MS Excel MVP


"Steve_n_KC" wrote in message
...
Assuming it's possible, could someone help me with the macro code to get all
the file names, regardless of type, within a specific folder and then list
those names including as much as possible of the file path in a column of the
sheet that I execute the macro from?

If the macro can pull the info in as a hyperlink that would be a bonus but I
can work that separately if needed.

I need this to be something that I can assign to a button so that the user
can update the list prior to each use.
--
THANKS!

Steve




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default hyperlink to files

Thanks Again! I'm especially appreciative of the inclusion of the message
boxes and the " '.SearchSubFolders = True"...answering questions before they
are asked!!

Could you tell now tell me if it is possible modify the code to still return
the hyperlinks but only display the file name (preferably without the
extension)??

When I asked my original question I planned on being able to select "Edit
Hyperlink" and assign a vanity name to the link but it isn't a listed option
for these cells???
--
THANKS!

Steve


"Bernie Deitrick" wrote:

And if you just want the hyperlink:

Sub FindFilesAndHyperlink2ThemV2()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Folder"
' .SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).FormulaR1C1 = "=HYPERLINK(""" & .FoundFiles(i) & """)"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub


--
HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Steve,

Change the .LookIn path as needed.... The list will start in the activecell

Sub FindFilesAndHyperlink2Them()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Foler"
'.SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).Value = .FoundFiles(i)
ActiveCell.Cells(i, 2).FormulaR1C1 = "=HYPERLINK(RC[-1])"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub



HTH,
Bernie
MS Excel MVP


"Steve_n_KC" wrote in message
...
Assuming it's possible, could someone help me with the macro code to get all
the file names, regardless of type, within a specific folder and then list
those names including as much as possible of the file path in a column of the
sheet that I execute the macro from?

If the macro can pull the info in as a hyperlink that would be a bonus but I
can work that separately if needed.

I need this to be something that I can assign to a button so that the user
can update the list prior to each use.
--
THANKS!

Steve








  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default hyperlink to files

Steve,

Try the macro below.

HTH,
Bernie
MS Excel MVP


Sub FindFilesAndHyperlink2ThemV3()
Dim i As Integer
Dim myF As String

With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Folder"
' .SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count

myF = Mid(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)
myF = Left(myF, Len(myF) - 4)
ActiveCell.Cells(i, 1).FormulaR1C1 = _
"=HYPERLINK(""" & .FoundFiles(i) & """,""Click to open " & myF &
""")"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub

"Steve_n_KC" wrote in message
...
Thanks Again! I'm especially appreciative of the inclusion of the message
boxes and the " '.SearchSubFolders = True"...answering questions before
they
are asked!!

Could you tell now tell me if it is possible modify the code to still
return
the hyperlinks but only display the file name (preferably without the
extension)??

When I asked my original question I planned on being able to select "Edit
Hyperlink" and assign a vanity name to the link but it isn't a listed
option
for these cells???
--
THANKS!

Steve


"Bernie Deitrick" wrote:

And if you just want the hyperlink:

Sub FindFilesAndHyperlink2ThemV2()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Folder"
' .SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).FormulaR1C1 = "=HYPERLINK(""" &
.FoundFiles(i) & """)"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub


--
HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Steve,

Change the .LookIn path as needed.... The list will start in the
activecell

Sub FindFilesAndHyperlink2Them()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Foler"
'.SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).Value = .FoundFiles(i)
ActiveCell.Cells(i, 2).FormulaR1C1 = "=HYPERLINK(RC[-1])"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub



HTH,
Bernie
MS Excel MVP


"Steve_n_KC" wrote in message
...
Assuming it's possible, could someone help me with the macro code to
get all
the file names, regardless of type, within a specific folder and then
list
those names including as much as possible of the file path in a column
of the
sheet that I execute the macro from?

If the macro can pull the info in as a hyperlink that would be a bonus
but I
can work that separately if needed.

I need this to be something that I can assign to a button so that the
user
can update the list prior to each use.
--
THANKS!

Steve







  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default hyperlink to files

You may get tired of hearing it but...Works PERFECT! 3 for 3!!!
--
THANKS!

Steve


"Bernie Deitrick" wrote:

Steve,

Try the macro below.

HTH,
Bernie
MS Excel MVP


Sub FindFilesAndHyperlink2ThemV3()
Dim i As Integer
Dim myF As String

With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Folder"
' .SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count

myF = Mid(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)
myF = Left(myF, Len(myF) - 4)
ActiveCell.Cells(i, 1).FormulaR1C1 = _
"=HYPERLINK(""" & .FoundFiles(i) & """,""Click to open " & myF &
""")"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub

"Steve_n_KC" wrote in message
...
Thanks Again! I'm especially appreciative of the inclusion of the message
boxes and the " '.SearchSubFolders = True"...answering questions before
they
are asked!!

Could you tell now tell me if it is possible modify the code to still
return
the hyperlinks but only display the file name (preferably without the
extension)??

When I asked my original question I planned on being able to select "Edit
Hyperlink" and assign a vanity name to the link but it isn't a listed
option
for these cells???
--
THANKS!

Steve


"Bernie Deitrick" wrote:

And if you just want the hyperlink:

Sub FindFilesAndHyperlink2ThemV2()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Folder"
' .SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).FormulaR1C1 = "=HYPERLINK(""" &
.FoundFiles(i) & """)"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub


--
HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Steve,

Change the .LookIn path as needed.... The list will start in the
activecell

Sub FindFilesAndHyperlink2Them()
Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Foldername\My Foler"
'.SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
ActiveCell.Cells(i, 1).Value = .FoundFiles(i)
ActiveCell.Cells(i, 2).FormulaR1C1 = "=HYPERLINK(RC[-1])"
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub



HTH,
Bernie
MS Excel MVP


"Steve_n_KC" wrote in message
...
Assuming it's possible, could someone help me with the macro code to
get all
the file names, regardless of type, within a specific folder and then
list
those names including as much as possible of the file path in a column
of the
sheet that I execute the macro from?

If the macro can pull the info in as a hyperlink that would be a bonus
but I
can work that separately if needed.

I need this to be something that I can assign to a button so that the
user
can update the list prior to each use.
--
THANKS!

Steve








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink files same folder only? dahljam Excel Discussion (Misc queries) 2 July 3rd 07 07:00 PM
hyperlink to files? [email protected] Excel Discussion (Misc queries) 4 June 22nd 07 08:56 PM
I can't open PDF files when using the hyperlink zwalbij Excel Worksheet Functions 12 March 10th 07 11:02 PM
hyperlink to files Andy Excel Worksheet Functions 1 November 9th 05 01:33 PM
hyperlink to jpg files wines4u Excel Discussion (Misc queries) 6 January 14th 05 12:31 AM


All times are GMT +1. The time now is 02:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"