On Feb 18, 6:17*am, Gokul <gokuln...@gmail.comwrote:
Hai all,
I need to write an Excel Macro to read a folder's content and to save
the filenames in an array of strings. But I dont know the commands to
use. Please help me with an idea. If possible, give a sample code
also.
Thanks,
Gokul
Try this macro in Excel,
Sub DirLoop()
Dim MyFile As String, Sep As String
Dim i As Integer
Sep = Application.PathSeparator
i = 1
Application.GetOpenFilename
MyFile = Dir(CurDir() & Sep & "*.*")
' Starts the loop, which will continue until there are no more
files found.
' Searches current directory only
Do While MyFile <""
'MsgBox CurDir() & Sep & MyFile
Range("A" & i).Value = MyFile
i = i + 1
MyFile = Dir() 'Get Next file
Loop
End Sub