Hi trend,
If you don't need the file size, then you can use the information from the
article "How to read the filenames of all the files in a directory into an
array" at http://word.mvps.org/faqs/macrosvba/ReadFilesIntoArray.htm
You would end up with something like the following:
Dim sPath As String
Dim MyFile As String
Dim Counter As Long
sPath = "c:\test\"
'Create a dynamic array variable, and then declare its initial size
Dim DirectoryListArray() As String
ReDim DirectoryListArray(1000)
'Loop through all the files in the directory by using Dir$ function
MyFile = Dir$(sPath & "*.mp3")
Do While MyFile <> ""
DirectoryListArray(Counter) = MyFile
MyFile = Dir$
Counter = Counter + 1
Loop
'Reset the size of the array without losing its values by using Redim
Preserve
ReDim Preserve DirectoryListArray(Counter - 1)
For Counter = 0 To UBound(DirectoryListArray)
sFileInfo = sFileInfo & Counter + 1 & vbTab
sFileInfo = sFileInfo & DirectoryListArray(Counter) & vbTab
sFileInfo = sFileInfo & FileLen("c:\test\" &
DirectoryListArray(Counter)) / 1000 & vbCrLf
Next Counter
MsgBox sFileInfo
This shows the size of the file in kilobytes (you have to help yourself some
to get it to megabytes). You will need to change the line
MyFile = Dir$(sPath & "*.mp3")
to
MyFile = Dir$(sPath & "*.M3U")
to account for the other file type.
HTH,
Dave
> need help to customize microsoft code a little:
> code sample:
[quoted text clipped - 19 lines]
>
> thanks.
TANDEX - 24 Mar 2005 20:00 GMT
> Hi trend,
>
[quoted text clipped - 66 lines]
>>
>> thanks.
---------------------------------
Dave,
I need list 'File name' and 'File size'(in Mb).
Also, how to implement way to retrieve the folder name that the user
selected by calling the standard 'Browse folder dialog'? i.e. implement
integrated browsing capability, to select required folder via browsing, more
easily. Currently code use just input box where exact patch to folder should
be entered manually.
Dave Lett - 24 Mar 2005 20:46 GMT
Hi,
You can call the Copy File dialog box to allow the user to navigate to a
folder. As for changing from kilobytes to megabytes, have a search on the
Internet or something and do a LITTLE to help yourself.
Dim sPath As String
Dim MyFile As String
Dim Counter As Long
With Dialogs(wdDialogCopyFile)
.Display
sPath = .Directory
End With
'Create a dynamic array variable, and then declare its initial size
Dim DirectoryListArray() As String
ReDim DirectoryListArray(1000)
'Loop through all the files in the directory by using Dir$ function
MyFile = Dir$(sPath & "*.doc")
Do While MyFile <> ""
DirectoryListArray(Counter) = MyFile
MyFile = Dir$
Counter = Counter + 1
Loop
'Reset the size of the array without losing its values by using Redim
Preserve
ReDim Preserve DirectoryListArray(Counter - 1)
For Counter = 0 To UBound(DirectoryListArray)
sFileInfo = sFileInfo & Counter + 1 & vbTab
sFileInfo = sFileInfo & DirectoryListArray(Counter) & vbTab
sFileInfo = sFileInfo & FileLen("c:\test\" &
DirectoryListArray(Counter)) / 1000 & vbCrLf
Next Counter
MsgBox sFileInfo
> > Hi trend,
> >
[quoted text clipped - 76 lines]
> easily. Currently code use just input box where exact patch to folder should
> be entered manually.
TANDEX - 24 Mar 2005 21:08 GMT
> Hi,
>
[quoted text clipped - 116 lines]
> should
>> be entered manually.
----------------
Hi,
I tried this code and it not work.
Dave Lett - 25 Mar 2005 14:21 GMT
Maybe you could be a little more specific that it not work?
Dave
> > Hi,
> >
[quoted text clipped - 121 lines]
>
> I tried this code and it not work.