Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default hyperlinks to files in all sub-directories

Thanks, Jim. I think I found the answer to my own question in another
posting. If any one is interested, here is the code. I don't like
that it displays the whole directory tree, I would like to just display
the filename. Not sure how to change that, but I can use a formula to
extract just the name. Thanks to whomever posted this:

Option Explicit


Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, _
ByVal pszPath As String) As Long


Private Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As Long


Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type


Dim FSO As Object
Dim cnt As Long
Dim level As Long
Dim arFiles


Sub ListFiles()
Dim i As Long
Dim sFolder As String
Application.Calculation = xlCalculationManual

Set FSO = CreateObject("Scripting.FileSystemObject")


arFiles = Array()
cnt = -1
level = 1


sFolder = GetFolder()
ReDim arFiles(1, 0)
If sFolder < "" Then
SelectFiles sFolder
Worksheets.Add.Name = "Files"
With ActiveSheet
For i = LBound(arFiles, 2) To UBound(arFiles, 2)
.Hyperlinks.Add Anchor:=.Cells(i + 1, arFiles(1,
0)), _
Address:=arFiles(0, i), _
TextToDisplay:=arFiles(0, i)
Next
End With
End If

Application.Calculation = xlCalculationAutomatic
End Sub

Thanks,
Steve Mackay

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
Stop Excel from locking files/directories you AREN'T working on? Your Display Name here... Excel Discussion (Misc queries) 1 November 20th 09 01:14 AM
How do I get excel files to open automatically from directories? Damian Excel Discussion (Misc queries) 2 January 3rd 06 02:51 PM
Hyperlinks to .pdf files comet Excel Worksheet Functions 1 December 7th 05 03:58 PM
Reference names and hyperlinks to other files in other directories Brains[_2_] Excel Programming 0 February 4th 04 02:01 PM
Listing files in directories. skmr3 Excel Programming 0 July 11th 03 12:50 AM


All times are GMT +1. The time now is 10:48 AM.

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

About Us

"It's about Microsoft Excel"