Trying to get My Computer / Search results into a worksheet

  • Thread starter Randy in Calgary
  • Start date
R

Randy in Calgary

I would like to use VBA from within an Excel workbook to run the Search
function of the My Computer dialog, and return the found files to a
worksheet. I am aware of the existence of the FileSearch object, but it
doesn't seem to give me the option to display a dialog box like that in My
Computer/Search to define the directories to be searched and the filters to
be used. The FileDialog object allows the selection of directories, but
seemingly only for one drive at a time (I would like to be able to search all
of My Computer).

Thanks for your help.
 
J

Jim Cone

If you want to search all drives then you don't have to select them from a dialog.
Just loop thru all of them and get the files from each one...
'--
Sub InterogateAllDrives()
'Jim Cone - Portland Oregon - June 2008
Dim oFSO As Object
Dim oAllDrives As Object
Dim oDrive As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oAllDrives = oFSO.drives
For Each oDrive In oAllDrives
If oDrive.IsReady Then

'do something with the files on the drive.

End If
Next 'oDrive

Set oDrive = Nothing
Set oAllDrives = Nothing
Set oFSO = Nothing
End Sub
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins - free trial of "List Files" - no registration)




"Randy in Calgary" <
(e-mail address removed)>
wrote in message
I would like to use VBA from within an Excel workbook to run the Search
function of the My Computer dialog, and return the found files to a
worksheet. I am aware of the existence of the FileSearch object, but it
doesn't seem to give me the option to display a dialog box like that in My
Computer/Search to define the directories to be searched and the filters to
be used. The FileDialog object allows the selection of directories, but
seemingly only for one drive at a time (I would like to be able to search all
of My Computer).
Thanks for your help.
 

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