Skip to main content

如何快速前往並打開Outlook中搜索結果的資料夾?

Author: Sun Last Modified: 2025-05-12

在Outlook中,您可以使用搜索功能根據特定文字來搜索郵件。但是,如果您正在搜索所有Outlook項目,則無法快速找到搜索結果所在的資料夾。在這種情況下,我這裡有一些技巧,可以幫助您快速前往並打開搜索結果的資料夾。

使用VBA前往並打開搜索結果的資料夾

使用右鍵單擊前往並打開搜索結果的資料夾


使用VBA前往並打開搜索結果的資料夾

在Outlook中,除了VBA代碼外,沒有內置功能可以處理此任務。

在使用VBA代碼之前,您需要在搜索結果中顯示資料夾名稱。

1. 點擊檢視 > 新增欄位

doc go to open folder of searching result 1

2. 在顯示欄位對話框中,在選擇可用欄位來源的下拉列表中選擇所有郵件欄位,然後在可用欄位列表中選擇所在資料夾

doc go to open folder of searching result 2

3. 點擊新增所在資料夾添加到按此順序顯示這些欄位列表中,然後點擊向上移動按鈕將所在資料夾移到頂部。

doc go to open folder of searching result 3

4. 點擊確定關閉對話框。現在,當您搜索郵件時,資料夾名稱將顯示在搜索結果中。

doc go to open folder of searching result 4

5. 現在按下 Alt + F11 鍵啟用 Microsoft Visual Basic for Applications 視窗,點擊 插入 > 模組 以創建一個新模組。

6. 複製並將以下代碼粘貼到模組中。

VBA:通過名稱前往資料夾

Sub FindFolderByName()
'UpdatebyExtendoffice20181105
    Dim xFldName As String
    Dim xFoundFolder As Folder
    Dim xYesNo As Integer
    On Error Resume Next
    xFldName = InputBox("Folder Name:", "Kutools for Outlook")
    If Len(Trim(xFldName)) = 0 Then Exit Sub
    Set xFoundFolder = ProcessFolders(Application.Session.Folders, xFldName)
    If xFoundFolder Is Nothing Then
        MsgBox "Not Found", vbInformation, "Kutools for Outlook"
        Exit Sub
    End If
    xYesNo = MsgBox("Activate Folder: " & vbCrLf & xFoundFolder.FolderPath, vbQuestion Or vbYesNo, "Kutools for Outlook")
    If xYesNo = vbNo Then Exit Sub
    Set Application.ActiveExplorer.CurrentFolder = xFoundFolder
End Sub
Function ProcessFolders(Flds As Outlook.Folders, Name As String)
    Dim xSubFolder As Outlook.MAPIFolder
    On Error Resume Next
    Set ProcessFolders = Nothing
    For Each xSubFolder In Flds
        If UCase(xSubFolder.Name) = UCase(Name) Then
            Set ProcessFolders = xSubFolder
            Exit For
        Else
            Set ProcessFolders = ProcessFolders(xSubFolder.Folders, Name)
            If Not ProcessFolders Is Nothing Then Exit For
        End If
    Next
End Function

7. 按下 F5 鍵啟用代碼,現在在對話框中輸入您要前往的資料夾名稱。

doc go to open folder of searching result 5

8. 點擊確定,彈出一個對話框提醒您資料夾的位置,點擊直接前往該資料夾,或點擊取消。

doc go to open folder of searching result 6

使用右鍵單擊前往並打開搜索結果的資料夾

如果您有 Kutools for Outlook,右鍵菜單中會嵌入一個打開所在資料夾 (KUTOOLS) 的工具,即使在搜索結果列表中,也能快速前往所選郵件的資料夾。

 ? Kutools for Outlook 現在有免費版本,其 70+ 功能終身免費。立即下載免費版本

免費安裝 Kutools for Outlook,然後按照以下步驟操作:

搜索後,右鍵單擊您想打開其資料夾的結果,從上下文菜單中選擇 打開所在資料夾 (KUTOOLS)

doc-click-open-folder