2014-08-28 74 views
0

我有許多組織,每個組織的列表。有數百人的列表,每個人在該組織文件夾中都有一個scan'd文檔,現在我的應用程序打開了org文件夾,並且用戶正在搜索該用戶,但用戶希望btn打開Windows資源管理器自動搜索一個人。搜索文件與Windows資源管理器

,我發現這個代碼:

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

但Windows提出如下因素的錯誤:

Windows Cant find ". Check if spaled correctly... 

有什麼建議?

我在這裏添加我的代碼:

Private Sub cmdView_Click() 
    Dim strPath As String 
    strPath = CurrentProject.Path & "\Scans\" & DLookup("OrgName", "tblOrganizations", "ID=" & Me.OrgID) 
    'Shell "C:\WINDOWS\explorer.exe """ & strPath & "", vbNormalFocus 
    Call Shell("c:\Windows\explorer.exe ""search-ms:displayname=Search%20Results&crumb=System.Generic.String%3A" & Me.Phone & "&crumb=location:" & strPath & "%""", vbNormalFocus) 
End Sub 
+0

我想你錯過了另一個雙引號的地方......最有可能在你的命令結束。不要忘記逃避它。 – parakmiakos 2014-08-28 06:33:36

+0

謝謝,我會試着弄清楚 – 2014-08-28 15:01:33

+0

是的,你在explorer.exe後面有一個開頭轉義(加倍)報價,並且在最後沒有關閉。 – 2017-01-20 01:33:18

回答

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

這應該修復它,因爲parakmiakos說,你錯過了一個雙(三重由於是一個字符串)報價。

+0

我試過了,但仍然出現錯誤,請參閱我在代碼中添加的代碼。 – 2014-08-28 15:16:44

0
string folder = Uri.EscapeDataString(@"C:\"); 
      string file = "size:huge"; 
      string uri = "search:query=" + file + "&crumb=location:" + folder; 
      var files = Process.Start(new ProcessStartInfo(uri)); 
+0

這是C#和.NET。他要求MS Access。 – 2017-01-20 05:42:08

0

下面是一個簡單的解決方案,僅使用一個共同的批處理(.bat)文件,任何人都可以使僅使用Notepad.exe的:

:: Text to search for 
SET name=Winamp 

:: Directory to search in 
SET dir=C:\Program Files (x86) 

:: ** Command Line ** 
C:\Windows\Explorer.exe "search-ms:displayname=Search Results in %dir%&crumb=System.Generic.String:%name%&crumb=location:%dir%" 

-

  1. 要搜索的文本可以是要搜索的文件或目錄的全名或只是其名稱的一部分。

  2. 該搜索不區分大小寫,但會匹配大寫和小寫的混合。

  3. 該函數將搜索指定的目錄及其所有子目錄。

相關問題