Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Auto multiple links

115 views
Skip to first unread message

John

unread,
Feb 26, 2003, 4:41:09 PM2/26/03
to
How do I automatically generate links on a spreedsheet to
all of the files in a directory ?

Bill Manville

unread,
Feb 27, 2003, 4:58:17 AM2/27/03
to
John wrote:
> How do I automatically generate links on a spreedsheet to
> all of the files in a directory ?
>

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
R.CurrentRegion.Sort key1:=R, order1:=xlAscending, header:=xlNo
End Sub

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup

0 new messages