2016-06-24 10 views
0

VBAには比較的新しいので、エクスプローラで特定のフォルダを起動する作業に取り組んでいます。エクスプローラで名前を含むフォルダのファイルを検索します特定の文字列を検索し、その結果をエクスプローラに表示します。私はシェルを使っていて、特定のフォルダを個別に開き、検索を実行することができました...しかし、両方のタスクを同時に行う方法を理解できません。を指定したフォルダ内のエクスプローラで検索を実行

私が試したいくつかの異なることがあります:何も働いていません。

Sub search_Files() 

    Dim folderName As String 

    folderName = "\\Users\itsMe\Documents" 

    Call Shell("C:\WINDOWS\explorer.exe "" "" & folderName _ 
        &"" ""&search-ms://query=h&", vbNormalFocus) 

    Call Shell("explorer.exe "" ""search-ms:query=h&crumb=location:\\Users\itsMe\Documents", vbNormalFocus) 

    Call Shell("C:\WINDOWS\explorer.exe"" & FolderName &", vbNormalFocus) 

    RetVal = Shell(_ 
    "c:\Windows\explorer.exe ""search-ms:displayname=Search%20Results&crumb=\\Users\itsMe\Documents" _ 
    & h & "%20kind%3A%3Dfolder&crumb=location:" _ 
    & folderName, vbNormalFocus) 

End Sub 

誰かがこれを行う方法について正しいコードを教えてください。 (私はシェルを使用したい。)

答えて

0

これを試してみてください - それは私のために働いた...

Call Shell("explorer.exe " & Chr(34) & "search-ms:query=*.pdf&crumb=location:c:\ad\" & Chr(34), vbNormalFocus) 
0

あなたのコードを意味するかは、以下のように5つ目を交換する必要がありますか?私はすでに関連する宛先フォルダを変更しようとしています。しかし、まだ失敗します。私はどのステップで間違っていたかわからない。

Sub search_Files() 

    Dim folderName As String 

    folderName = "C:\Users\lkam\Documents" 

    Call Shell("C:\WINDOWS\explorer.exe "" "" & folderName _ 
        &"" ""&search-ms://query=h&", vbNormalFocus) 

    Call Shell("explorer.exe " & Chr(34) & "search-ms:query=*.pdf&crumb=location:c:\ad\" & Chr(34), vbNormalFocus) 

    Call Shell("C:\WINDOWS\explorer.exe"" & FolderName &", vbNormalFocus) 

    RetVal = Shell(_ 
    "c:\Windows\explorer.exe ""search-ms:displayname=Search%20Results&crumb=C:\Users\lkam\Documents" _ 
    & h & "%20kind%3A%3Dfolder&crumb=location:" _ 
    & folderName, vbNormalFocus) 

End Sub 
関連する問題