Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get the list of files in a folder

Can someone help me to get name of all the files in the
folder in excel with the hyperlinks to the same within
excel? It should be able to choose the folder by user so
that my all the users can use it. I have tried using macro
recorder but failed. This reqd for the companys huge data
base sorted and kept in different folders on the intranet.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default How to get the list of files in a folder

It might be better to have the list and then just use a double click event
to goto the file.

This should list the files

Sub GetFileList()
Dim iCtr As Integer

With Application.FileSearch
.NewSearch
.LookIn = "c:\yourfolder"
' .SearchSubFolders = True
.Filename = ".xls"
If .Execute 0 Then
For iCtr = 1 To .FoundFiles.Count
Cells(iCtr, 1).Value = .FoundFiles(iCtr)
Next iCtr
End If
End With
End Sub

Then this should goto the file by a double click on the typed name.
========
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.DisplayAlerts = False
Dim WantedSheet As String
WantedSheet = Trim(ActiveCell.Value)
If WantedSheet = "" Then Exit Sub
On Error Resume Next
If Sheets(ActiveCell.Value) Is Nothing Then
GetWorkbook ' calls another macro to do that
Else
Sheets(ActiveCell.Value).Select
ActiveSheet.Range("a4").Select
End If
Application.DisplayAlerts = True
End Sub

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows("" & workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
Exit Sub
End Sub
=========

"yang" wrote in message
...
Can someone help me to get name of all the files in the
folder in excel with the hyperlinks to the same within
excel? It should be able to choose the folder by user so
that my all the users can use it. I have tried using macro
recorder but failed. This reqd for the companys huge data
base sorted and kept in different folders on the intranet.



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
Read Files from a folder into an Excel drop down list or Combo Box dhstein Excel Discussion (Misc queries) 2 January 16th 09 05:41 PM
Creating a List of the files in a folder in excel [email protected] Excel Discussion (Misc queries) 2 November 27th 06 08:39 PM
how do i print a list of files in a folder in excel? mikie New Users to Excel 4 June 6th 05 04:27 AM
create a list of worksheet names (from a single folder, or open files) Drew Excel Discussion (Misc queries) 2 April 15th 05 04:58 PM
Getting list of files in a folder to excel Dave Peterson[_3_] Excel Programming 0 July 29th 03 02:47 AM


All times are GMT +1. The time now is 03:39 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"