troubleshooting Question

Use VBA to Reproduce Explorer "Copy As Path" option

Avatar of PeterFrb
PeterFrbFlag for United States of America asked on
Windows OSVBAMicrosoft Word
10 Comments2 Solutions38 ViewsLast Modified:
If I am doing a search through a number of files for a particular word ("Motor") or file configuration (".pdf"), I can, once the procedure is complete, press <Shift><Right Click>, and then left click on "Copy as Path".  That takes all the found elements and stores them to the clipboard, where I can paste them any where I want, i.e., a text file or Excel.  

I would like to replicate this functionality using VBA code.  I would like VBA to capture a whole series of folder/file paths, based on the search criteria given it.  I do know how to use vba to invoke a command prompt, and have the prompt run Explorer from a set folder:

Shell "Explorer C:\FindFiles\

What I don't know how to do is choose a search criteria when running Explorer, and I also don't know how to give VBA visibility to the files it has found.  What might also work is redirection (">") which produces sends command-line output elsewhere.  (i.e.,
Shell "Explorer C:\FindFiles\ > CopyAsPath.txt
).  (I realize that the previous example goes out on a limb, ss windows has become so dominant a part of the landscape, redirection is hardly in place any more.

Anything that will support VBA to see the results of a search is what I seek.  Thank you.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros