Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
Arvi Laanemets
 
Posts: n/a
Default copy file names

Hi

below are a couple od UDF's, combining which you can get the list of files
in any folder or subfolder. The optional parameter MyTime is used to make
formula recalculate {use TODAY() or NOW() as optional parameter}


Public Function GetSubfolder(MyFolder As String, FolderNum As Integer,
Optional MyTime As Date)
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 GetFileName(MyFolder As String, FileNum As Integer,
MyExtension As String, Optional MyTime As Date)
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 GetFileName = f1.Name
End If
Next
End Function


Public Function GetThisFolder(Optional MyTime As Date)
GetThisFolder = ThisWorkbook.Path
End Function


--
Arvi Laanemets
( My real mail address: arvil<attarkon.ee )



"covi2k2" wrote in
message ...

i want to copy file names in to excel to creat a list for a register of
files , is there a way to copy the names straight in to excel or woul
di have to type them all in

robert


--
covi2k2
------------------------------------------------------------------------
covi2k2's Profile:
http://www.excelforum.com/member.php...o&userid=28078
View this thread: http://www.excelforum.com/showthread...hreadid=485861



 
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
copy worksheet to a new workbook with formulas .... but new file not point to old one newToExcel Excel Discussion (Misc queries) 7 November 13th 05 09:55 PM
Links picking up values from an older version of linked file Cate Links and Linking in Excel 4 October 20th 05 01:53 PM
need to copy a long list of file names gilcola Excel Discussion (Misc queries) 6 August 19th 05 12:55 AM
COPY CELL WITH FILE REFERENCES IN EXCEL natelee78 Excel Discussion (Misc queries) 4 July 12th 05 02:15 PM
Copy sheet to a new file Pete Excel Discussion (Misc queries) 3 February 5th 05 10:37 PM


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