Displaying the Find Dialog

Do your users need to search for files?

Give them a helping hand and bring up the Find Files dialog box with this handy code snippet.

To run, just call the ShowFindDialog method, passing an optional directory to search.

Note: If you pass an invalid directory, the Find Files dialog will not appear. If you don’t pass a directory, the ‘current’ directory will be automatically selected.

Usage

Call ShowFindDialog("e:\karl\")

Code

Declare Function ShellExecute Lib "shell32.dll" Alias _
    "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
    As String, ByVal lpFile As String, ByVal lpParameters _
    As String, ByVal lpDirectory As String, ByVal nShowCmd _
    As Long) As Long
   
Const SW_SHOW = 5

Public Sub ShowFindDialog(Optional InitialDirectory As String)

ShellExecute 0, "find", _
  IIf(InitialDirectory = "", "", InitialDirectory), _
  vbNullString, vbNullString, SW_SHOW

End Sub


Linkexchange Discussion | Venetian Blinds | Mikes Journal | Help with Window Blinds | Cheryls Blog