Excel

Show The Windows Search Results Dialog

Ease of Use

Easy

Version tested with

2000, 2002 

Submitted by:

Justinlabenne

Description:

Shows the Windows Search Results Dialog 

Discussion:

If you need your users to locate other files to work with but you don't have any knowledge as the the directory location or possibly even the type of file, or even the correct name, an option is to use the natvie Windows Search Results dialog. The dialog can be shown via code and it allows the user many options and criteria to specifiy when they need to search for a file and many variables are involved in the search. You can also specifiy an initial drive to search. 

Code:

instructions for use

			

Option Explicit 'API declaration for the windows "Search Results" dialog Private Declare Function ShellSearch& 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) Private Const SW_SHOWNORMAL = 1 Sub ShowWindowsSearchDialog_API() ' Specified drive to Search Const szSDrive As String = "C:\" ShellSearch 0, "find", szSDrive, "", "", SW_SHOWNORMAL End Sub

How to use:

  1. Open an Excel Workbook
  2. Copy the code
  3. Press Alt + F11 to open the Visual Basic Editor (VBE)
  4. Select INSERT > MODULE from the menubar
  5. Paste code into the right pane
  6. Press Alt+Q to return to Excel
  7. Save workbook before any other changes
 

Test the code:

  1. Go to TOOLS > MACRO > MACROS
  2. When the dialog appears, select {ShowWindowsSearchDialog_API}
  3. Press Run
 

Sample File:

SearchDialog_API.zip 7.05KB 

Approved by mdmackillop


This entry has been viewed 208 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express