Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hyperlink to a folder

Status
Not open for further replies.

Ferntown

Technical User
Jan 15, 2004
11
CA
I've looked for a similar topic but I can't find one so here it goes. I would like to have a command button on a form that opens a folder that contains a bunch of excel files. I would like the user to be able to open any one of the files from here. Would I use a hyperlink? Is this possible or is there a better way.
Thanks,
Ruby
 
You can use this code in the on click event of your command button:

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)

Dim FileXL As Variant
With fd
.Filters.Add "Excel Files", "*.xls", 1
.InitialFileName = "C:\"
If .Show = -1 Then
For Each FileXL In .SelectedItems
Workbooks.Open Filename:=FileXL
Next FileXL
Else
End If
End With

Change the path of the InitialFileName to the path of your folder.
You will need a reference to the microsoft office x.x object library.

HTH,
Eric
 
Sorry. That only works within Excel itself. Try this instead:


Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)

Dim FileXL As Variant
With fd
.AllowMultiSelect = False
.Filters.Add "Excel Files", "*.xls", 1
.InitialFileName = "C:\"
If .Show = -1 Then

For Each FileXL In .SelectedItems

stAppName = "C:\Program Files\Microsoft Office\Office10\excel.exe " & FileXL
Call Shell(stAppName, 1)
Next
End If
End With



Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top