Skip to main content

如何將 Outlook 資料夾結構複製到桌面(Windows 資源管理器)?

Author: Kelly Last Modified: 2025-08-06

眾所周知,我們可以使用封存功能將資料夾結構複製到另一個 Outlook,但您是否知道如何將 Outlook 的資料夾結構複製到特定的 Windows 資料夾,例如桌面呢?本文將介紹一種 VBA 方法,讓您輕鬆將 Outlook 資料夾結構複製到 Windows 資源管理器。

將 Outlook 資料夾結構複製到桌面(Windows 資源管理器)


將 Outlook 資料夾結構複製到桌面(Windows 資源管理器)

請按照以下步驟將 Outlook 資料夾結構複製到桌面或 Windows 資源管理器。

1. 在導覽窗格中,請點擊以突出顯示要複製其資料夾結構的指定資料夾,然後按下「Alt」+「F11」鍵以打開 Microsoft Visual Basic for Applications 窗口。

the screenshot of step about copying Outlook folder structure to desktop (windows explorer) using vba 1

2. 點擊「工具」>「引用」以打開引用對話框。然後在對話框中勾選「Microsoft Scripting Runtime」選項,並點擊「確定」按鈕。參見截圖:

the screenshot of step about copying Outlook folder structure to desktop (windows explorer) using vba 2

3. 點擊「插入」>「模組」,並將以下 VBA 代碼複製並粘貼到新的模組窗口中。

VBA:將 Outlook 資料夾結構複製到 Windows 資源管理器

Dim xFSO As Scripting.FileSystemObject
Sub CopyOutlookFldStructureToWinExplorer()
    ExportAction "Copy"
End Sub
  
Sub ExportAction(xAction As String)
Dim xFolder As Outlook.Folder
Dim xFldPath As String
xFldPath = SelectAFolder()
If xFldPath = "" Then
    MsgBox "You did not select a folder. Export cancelled.", vbInformation + vbOKOnly, "Kutools for Outlook"
Else
    Set xFSO = New Scripting.FileSystemObject
    Set xFolder = Outlook.Application.ActiveExplorer.CurrentFolder
    ExportOutlookFolder xFolder, xFldPath
End If
Set xFolder = Nothing
Set xFSO = Nothing
End Sub

Sub ExportOutlookFolder(ByVal OutlookFolder As Outlook.Folder, xFldPath As String)
Dim xSubFld As Outlook.Folder
Dim xItem As Object
Dim xPath As String
Dim xFilePath As String
Dim xSubject As String
Dim xCount As Integer
Dim xFilename As String
On Error Resume Next
xPath = xFldPath & "\" & OutlookFolder.Name
'?????????,??????
If Dir(xPath, 16) = Empty Then MkDir xPath
For Each xItem In OutlookFolder.Items
    xSubject = ReplaceInvalidCharacters(xItem.Subject)
    xFilename = xSubject & ".msg"
    xCount = 0
    xFilePath = xPath & "\" & xFilename
    If xFSO.FileExists(xFilePath) Then
        xCount = xCount + 1
        xFilename = xSubject & " (" & xCount & ").msg"
        xFilePath = xPath & "\" & xFilename
    End If
    xItem.SaveAs xFilePath, olMSG
Next
For Each xSubFld In OutlookFolder.Folders
    ExportOutlookFolder xSubFld, xPath
Next
Set OutlookFolder = Nothing
Set xItem = Nothing
End Sub

Function SelectAFolder() As String
Dim xSelFolder As Object
Dim xShell As Object
On Error Resume Next
Set xShell = CreateObject("Shell.Application")
Set xSelFolder = xShell.BrowseForFolder(0, "Select a folder", 0, 0)
If Not TypeName(xSelFolder) = "Nothing" Then
    SelectAFolder = xSelFolder.self.Path
End If
Set xSelFolder = Nothing
Set xShell = Nothing
End Function
  
Function ReplaceInvalidCharacters(Str As String) As String
Dim xRegEx
Set xRegEx = CreateObject("vbscript.regexp")
xRegEx.Global = True
xRegEx.IgnoreCase = False
xRegEx.Pattern = "\||\/|\<|\>|""|:|\*|\\|\?"
ReplaceInvalidCharacters = xRegEx.Replace(Str, "")
End Function

4. 按下「F5」鍵或點擊「運行」按鈕來執行此 VBA。

5. 在彈出的「瀏覽資料夾」對話框中,請選擇要放置複製的資料夾結構的指定資料夾,然後點擊「確定」按鈕。參見截圖:

the screenshot of step about copying Outlook folder structure to desktop (windows explorer) using vba 3

現在進入指定的資料夾,您會看到資料夾結構已複製到指定的硬碟中。參見截圖:

the screenshot of step about copying Outlook folder structure to desktop (windows explorer) using vba 4

注意:資料夾中的項目,例如郵件、約會、任務等,也會被複製到硬碟中相應的資料夾中。


相關文章

如何在 Outlook 中將資料夾結構複製到新的 pst 數據文件?


最佳 Office 生產力工具

最新消息:Kutools for Outlook 推出免費版本!

體驗全新 Kutools for Outlook,擁有100+ 強大功能!立即下載!

🤖 Kutools AI 運用先進 AI 技術,輕鬆處理郵件,包括答覆、摘要、優化、擴寫、翻譯與撰寫郵件。

📧 郵件自動化自動回覆(支援 POP 和 IMAP) / 計劃發送郵件 / 發送郵件時根據規則自動抄送密送 / 自動轉發(高級規則) / 自動新增問候語 / 自動將多收件人郵件分割為個別郵件 ...

📨 郵件管理撤回郵件 /依主題等條件阻擋詐騙郵件 / 刪除重複郵件 / 高級搜索 / 整合文件夾 ...

📁 附件專業版批次保存 / 批次拆離 / 批次壓縮 / 自動保存 / 自動拆離 / 自動壓縮 ...

🌟 介面魔法😊更多精美酷炫表情符號 /重要郵件來臨提醒 / 最小化 Outlook 而非關閉 ...

👍 一鍵神技帶附件全部答復 /反釣魚郵件 / 🕘顯示發件人時區 ...

👩🏼‍🤝‍👩🏻 聯絡人與日曆批次從選中郵件新增聯絡人 / 將聯絡人組分割為多個組 / 移除生日提醒 ...

以您偏好的語言使用 Kutools —— 支援英語、西班牙語、德語、法語、中文及40 多種其他語言!

只需一鍵即可立即啟用 Kutools for Outlook。立即下載,提升您的效率!

kutools for outlook features1 kutools for outlook features2