Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
solrac1956
 
Posts: n/a
Default How do I import Names of Windows files into an Excel Spread sheet

How do I import Names of Windows files or folders into an Excel Spread sheet?

Please e-mail me at
  #2   Report Post  
Arvi Laanemets
 
Posts: n/a
Default

Hi

Copy the function GetMyFile() from below into workbooks module.

P.e. into cell A2 enter the formula like:
=IF(GetMyFile("C:\Documents and Settings\User\My
Documents\";ROW()-1;"xls")=0;"";GetMyFile("E:\Documents and Settings\User\My
Documents\";ROW()-1;"xls"))
and copy it down for at least as much rows, as you have files of type, you
are searching for, in this folder.

Additionally below is the function GetSubFolder(), which allows you to
create a list of subfolders for determined folder. You can combine both
functions, to ge a table of files in subfolders of some certain folder.


Arvi Laanemets


*****

Public Function GetSubfolder(MyFolder As String, FolderNum As Integer)
Dim fs, f, f1, s, sf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(MyFolder)
Set sf = f.SubFolders
i = 0
For Each f1 In sf
i = i + 1
If i = FolderNum Then GetSubfolder = f1.Name
Next
End Function

Public Function GetMyFile(MyFolder As String, FileNum As Integer,
MyExtension As String)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(MyFolder)
Set fc = f.Files
i = 0
For Each f1 In fc
If Right(f1.Name, 3) = MyExtension Then
i = i + 1
If i = FileNum Then GetMyFile = f1.Name
End If
Next
End Function


"solrac1956" wrote in message
...
How do I import Names of Windows files or folders into an Excel Spread

sheet?

Please e-mail me at



  #3   Report Post  
solrac1956
 
Posts: n/a
Default

Arvi Laanemets;

Thank you for your help. Please clarify;

1.) What is the Excel Worksheets Module?
2.) What Aruments should I watch for?


"solrac1956" wrote:

How do I import Names of Windows files or folders into an Excel Spread sheet?

Please e-mail me at

  #4   Report Post  
Arvi Laanemets
 
Posts: n/a
Default

Hi


"solrac1956" wrote in message
...
Arvi Laanemets;

Thank you for your help. Please clarify;

1.) What is the Excel Worksheets Module?


NB! WORKBOOK's module!

Open your Excel workbook. Activate VBA editor (Alt+F11). Unless you have
some module in workbook (you can see them in VBA project window at top left
corner in modules section of your project, i.e your workbook), insert one
(select Module from Insert menu). When the module isnīt activated jet (VBA
editor window is empty), then activate the module (double-click on it in VBA
project window). Copy function(s) into module. Vlose VBA editor.


2.) What Aruments should I watch for?


For GetMyFile():
1) Full path of folder, from where file names are retrieved, enclosed in
quotes;
2) The order number of file of searched type in this folder (1 - first;
2 - second etc.);
3) the file extension, enclode in quotes - determines file type the
search is performed for.




"solrac1956" wrote:

How do I import Names of Windows files or folders into an Excel Spread

sheet?

Please e-mail me at



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
Excel files in separate program windows Jason Dove Excel Discussion (Misc queries) 27 October 24th 08 07:58 PM
Import data from files with different names to EXCEL D'base. thunderfoot Excel Discussion (Misc queries) 2 June 10th 05 11:05 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
batch import dat files The Real Jd Excel Discussion (Misc queries) 2 February 16th 05 12:35 PM
Can I import a windows explorer list of files into an Excel sprea. skeliher Excel Discussion (Misc queries) 2 December 1st 04 10:24 PM


All times are GMT +1. The time now is 11:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Đ2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"