ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Addendum to question (https://www.excelbanter.com/excel-programming/422760-re-addendum-question.html)

Rick Rothstein

Addendum to question
 
I think this macro will do what you want (just change the values I have
assigned in the Const statements to those for your actual setup)...

Sub MakeHyperlinks()
Dim FN As String
Dim RowLoc As Long

Const StartRow As String = 3
Const HyperlinkCol As String = "B"
Const SheetName As String = "Sheet4"
Const DirPath As String = "C:\TEMP\Test\" 'Note the backslash

FN = Dir(DirPath & "*.*")
RowLoc = StartRow
With Worksheets(SheetName)
Do While Len(FN) 0
.Hyperlinks.Add Anchor:=.Cells(RowLoc, HyperlinkCol), _
Address:=DirPath & FN, TextToDisplay:=FN
RowLoc = RowLoc + 1
FN = Dir
Loop
End With
End Sub

--
Rick (MVP - Excel)


"RickD" wrote in message
...
I meant file in the last sentence.

here is an example of what I want to do:

upon opening 8121.xls
directory j:\{name of directory to search} is searched and the filename
of all files found are entered into a table as hyper-links

HTH

RickD


"RickD" wrote in message
...
Using Excel 2003

I'd like to create a dynamic table of file names that are located in a
certain directory when the workbook opens and then be able to display,
with the default application, any one of the folders

Thanks in advance

RickD





RickD[_2_]

Addendum to question
 
Thank you Rick,

I will test and report back

RickD

"Rick Rothstein" wrote in message
...
I think this macro will do what you want (just change the values I have
assigned in the Const statements to those for your actual setup)...

Sub MakeHyperlinks()
Dim FN As String
Dim RowLoc As Long

Const StartRow As String = 3
Const HyperlinkCol As String = "B"
Const SheetName As String = "Sheet4"
Const DirPath As String = "C:\TEMP\Test\" 'Note the backslash

FN = Dir(DirPath & "*.*")
RowLoc = StartRow
With Worksheets(SheetName)
Do While Len(FN) 0
.Hyperlinks.Add Anchor:=.Cells(RowLoc, HyperlinkCol), _
Address:=DirPath & FN, TextToDisplay:=FN
RowLoc = RowLoc + 1
FN = Dir
Loop
End With
End Sub

--
Rick (MVP - Excel)


"RickD" wrote in message
...
I meant file in the last sentence.

here is an example of what I want to do:

upon opening 8121.xls
directory j:\{name of directory to search} is searched and the
filename of all files found are entered into a table as hyper-links

HTH

RickD


"RickD" wrote in message
...
Using Excel 2003

I'd like to create a dynamic table of file names that are located in a
certain directory when the workbook opens and then be able to display,
with the default application, any one of the folders

Thanks in advance

RickD








All times are GMT +1. The time now is 01:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com