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

Hi,

I searched the newsgroup and found some code that gives me hyperlinks
to files in a directory. In addition to linking to files in the
directory, is it possible to link to files in all of the sub-folders of
the directory?

For instance, if I have a folder C:\Steve\ with several files and some
sub folders (C:\Steve\Folder1\ and C:\Steve\Folder2\ etc.) each with
several files, I want to be able to run a macro that would make links
to all the files just by inputting the first directory C:\Steve\. Is
this possible?

Ideally, I would like a new worksheet for each folder having the same
name as that folder, but this is more of a bonus. The part above is
what I really need.

Here is the code I have so far (thanks to Bill Manville):

Sub HyperlinksToDirectory()
' puts hyperlinks to each of the files in a directory of your choice
' into the active sheet starting at the active cell
Dim stDir As String
Dim stFile As String
Dim R As Range
Set R = ActiveCell
stDir = InputBox("Directory?", , Default:=CurDir())
stFile = Dir(stDir & "\*.*")
Do Until stFile = ""
R.Hyperlinks.Add R, stDir & "\" & stFile, , , stFile
Set R = R.Offset(1)
stFile = Dir()
Loop
End Sub

Thanks,
Steve Mackay

 
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 03:38 PM.

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"