Excel 2013 VBA ShellExecute with search box initialized

mrcpu

New Member
Joined
Nov 26, 2010
Messages
6
Using the following brief code snippet:

Code:
[COLOR=#00008B][FONT=Consolas]Option[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] Explicit [/FONT][/COLOR]
<code style="margin: 0px; padding: 0px; border: 0px; font-size: 13.63636302948px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"> [COLOR=#808080]'API declaration for the windows "Search Results" dialog
[/COLOR][COLOR=#00008B]Private[/COLOR] [COLOR=#00008B]Declare[/COLOR] [COLOR=#00008B]Function[/COLOR] ShellSearch& [COLOR=#00008B]Lib[/COLOR] [COLOR=#800000]"shell32.dll"[/COLOR] _
[COLOR=#00008B]Alias[/COLOR] [COLOR=#800000]"ShellExecuteA"[/COLOR] ([COLOR=#00008B]ByVal[/COLOR] hwnd [COLOR=#00008B]As[/COLOR] [COLOR=#00008B]Long[/COLOR], _
[COLOR=#00008B]ByVal[/COLOR] lpOperation [COLOR=#00008B]As[/COLOR] [COLOR=#00008B]String[/COLOR], _
[COLOR=#00008B]ByVal[/COLOR] lpFile [COLOR=#00008B]As[/COLOR] [COLOR=#00008B]String[/COLOR], [COLOR=#00008B]ByVal[/COLOR] lpParameters [COLOR=#00008B]As[/COLOR] [COLOR=#00008B]String[/COLOR], _
[COLOR=#00008B]ByVal[/COLOR] lpDirectory [COLOR=#00008B]As[/COLOR] [COLOR=#00008B]String[/COLOR], _
[COLOR=#00008B]ByVal[/COLOR] nShowCmd [COLOR=#00008B]As[/COLOR] [COLOR=#00008B]Long[/COLOR])

[COLOR=#00008B]Private[/COLOR] [COLOR=#00008B]Const[/COLOR] SW_SHOWNORMAL = [COLOR=#800000]1
[/COLOR][COLOR=#00008B]Sub[/COLOR] ShowWindowsSearchDialog_API()
     [COLOR=#808080]'   Specified drive to Search
[/COLOR]    [COLOR=#00008B]Const[/COLOR] szSDrive [COLOR=#00008B]As[/COLOR] [COLOR=#00008B]String[/COLOR] = [COLOR=#800000]"C:\"
[/COLOR]    ShellSearch [COLOR=#800000]0[/COLOR], [COLOR=#800000]"find"[/COLOR], szSDrive, [COLOR=#800000]""[/COLOR], [COLOR=#800000]""[/COLOR], SW_SHOWNORMAL 
</code>[COLOR=#00008B][FONT=Consolas]End[/FONT][/COLOR][COLOR=#00008B][FONT=Consolas]Sub
[/FONT][/COLOR]

It opens the search dialog box in explorer at the spot I want it to just peachy.

But how do I pre-initialize the search parameters? The 4th option is supposed to be some kind of parameter list, but I could only find c++ documentation on msdn, and it didn't read like it was an option. I've tried a couple variations, but nothing seems to take. I hate the thoughts of using something like sendkeys. Not even sure if sendkeys can DTRT.

Any help appreciated.

A bit of additional info:
For a variety of poor reasons, some reports get dumped into a mishmash hierarchy of folders, but with consistent naming of the reports but inconsisten naming of the folders. So I want to just search with explorer, they can control-a/control-C/control-v them into their own working folder for further processing.
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Watch MrExcel Video

Forum statistics

Threads
1,122,491
Messages
5,596,474
Members
414,070
Latest member
DuncanLucas

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top