Skip to main content

如何在Outlook中按名稱查找資料夾?

Author: Siluvia Last Modified: 2025-05-12

例如,您在Outlook中創建了許多郵件資料夾,當需要打開某個指定的個人資料夾時,您必須展開多個資料夾直到找到該指定的資料夾。為了打開一個指定的個人資料夾而逐一展開多個資料夾是非常麻煩的。實際上,如果您記住了資料夾名稱,所有事情都會變得簡單。在本教程中,我們將向您介紹一種通過名稱查找Outlook中的資料夾的方法,而不是逐個展開資料夾來查找目標資料夾。

使用VBA代碼在Outlook中按名稱查找資料夾

使用Kutools for Outlook跨帳戶按名稱搜索資料夾good idea3


使用VBA代碼在Outlook中按名稱查找資料夾

使用以下VBA代碼,您可以輕鬆地通過名稱查找指定的資料夾。

便簽:您需要記住資料夾名稱才能使用此VBA代碼。

1. 按鍵盤上的 Alt + F11 鍵以打開 Microsoft Visual Basic for Applications 窗口。

2. 然後雙擊 Project1 > Microsoft Outlook Object > ThisOutlookSession 以打開 Project1 – ThisOutlookSession 窗口。請參見截圖:

the screenshot of step about finding folder by name in Outlook with VBA code

3. 將以下VBA代碼複製並粘貼到 Project1 – ThisOutlookSession 窗口中。

VBA:按名稱查找資料夾

Sub FindFolderByName()
    Dim Name As String
    Dim FoundFolder As Folder
    
    Name = InputBox("Find Name:", "Search Folder")
    If Len(Trim$(Name)) = 0 Then Exit Sub
    
    Set FoundFouder = FindInFolders(Application.Session.Folders, Name)
    
  If Not FoundFouder Is Nothing Then
    If MsgBox("Activate Folder: " & vbCrLf & FoundFouder.FolderPath, vbQuestion Or vbYesNo) = vbYes Then
      Set Application.ActiveExplorer.CurrentFolder = FoundFouder
    End If
  Else
    MsgBox "Not Found", vbInformation
  End If
End Sub
Function FindInFolders(TheFolders As Outlook.Folders, Name As String)
  Dim SubFolder As Outlook.MAPIFolder
  
  On Error Resume Next
  
  Set FindInFolders = Nothing
  
  For Each SubFolder In TheFolders
    If LCase(SubFolder.Name) Like LCase(Name) Then
      Set FindInFolders = SubFolder
      Exit For
    Else
      Set FindInFolders = FindInFolders(SubFolder.Folders, Name)
      If Not FindInFolders Is Nothing Then Exit For
    End If
  Next
End Function 

4. 然後按鍵盤上的 F5 鍵運行VBA代碼。

5. 在「」對話框中,點擊「執行」按鈕。

the screenshot of step 2 about finding folder by name in Outlook with VBA code

6. 在彈出的「搜索資料夾」對話框中,請在文本框中輸入資料夾名稱,然後點擊「確定」按鈕。請參見截圖:

the screenshot of step 3 about finding folder by name in Outlook with VBA code

7. 然後會彈出一個 Microsoft Outlook 對話框,顯示您所需資料夾的路徑,然後點擊「」按鈕。

the screenshot of step 4 about finding folder by name in Outlook with VBA code

8. 然後指定的郵件資料夾將立即打開。

便簽:此VBA代碼適用於Outlook 2007、2010和2013。


使用Kutools for Outlook跨帳戶按名稱搜索資料夾

如果您不擅長VBA,可以嘗試 Kutools for Outlook 的「打開資料夾」功能,它能夠通過名稱或特定字符查找和搜索資料夾,然後直接進入該資料夾。

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

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

1. 點擊 Kutools Plus > 資料夾 > 打開資料夾

doc find folder by name 5

2. 在「打開資料夾」對話框中,在搜索欄中輸入資料夾名稱或特定字符,然後相關的資料夾將列出。

doc find folder by name 6

3. 雙擊您要前往並打開的資料夾名稱,然後該資料夾就會打開。

doc find folder by name 7