Open explorer search from excel hyperlink [closed]

2019-08-26 12:30发布

问题:

I am working on a project, and my current goal is to write a script for excel that will open a windows explorer search to an already set location, searching for the cell value.

I think this would be easiest with shell, but I just can't find out how to do this with a command in cmd.

I have found lots of stuff opening finder and explorer(even on the exact file location), but I just can't combine them to search for the file I would add in a variable in the exact location.

I am thinking of something like this:

https://superuser.com/questions/499238/command-to-open-windows-explorer-window-with-filtered-results

Edit: what I was trying to say is that, for example, I have a place on a server where all my computer backups automatically gets saved with the backup name <pcname+backup date>. I also have a list where all my computer names are listed:

asdpc-1

asdpc-2

asdpc-3

In my excel list, those are made hyperlinks. My goal is: when I click on asdpc-1, it will open a window in explorer for me with the computer name in the search box, searching the server for asdpc-1's backup. I found this the best solution because of the date of the backup also gets included in the name. So this way I can see all the backups made for this pc.

I figured it out that I had some syntax problems, and I fixed it by now, so it's working fine as expected.

回答1:

ok I found the answer and it only took me 3 houres :-)

Shell("c:\Windows\explorer.exe ""search-ms:displayname=Search%20Results&crumb=System.Generic.String%3A" & <variable> & "&crumb=location:<your search location>%", vbNormalFocus)

to add location it is easyest to do the search manually just the way you want it to work, than copy the text after the "location:"