Macro Suggestion Needed

K

K

Hi all, I got macro (see below) which opens up the "Browse Folder"
window and then when I select any Folder from it and press ok it
diplay all kind of files in that folder into the List Box which is on
my sheet. My question is that I created this macro doing search on
this group and i dont know any side effects of this macro (like
failing to produce result or give error in future) so can please any
friend know any simple macro to do the same job or any suggestions or
any other macro to make this job perfect.

Sub GetFiles()
Sheets("Group Emailer").ListBox1.Clear
Dim Filename As String
Dim Foldername As String
Dim objShell
Dim objFolder

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.browseforfolder(0, "CHOSE FOLDER:", 0, 17)

If (Not objFolder Is Nothing) Then
Foldername = objFolder.self.Path & "\"
Filename = Dir(Foldername)
Do Until Filename = ""
Sheets("Group Emailer").ListBox1.AddItem (Filename)
Filename = Dir
Loop
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top