如何將 Outlook 資料夾結構複製到桌面(Windows 資源管理器)?
眾所周知,我們可以使用封存功能將資料夾結構複製到另一個 Outlook,但您是否知道如何將 Outlook 的資料夾結構複製到特定的 Windows 資料夾,例如桌面呢?本文將介紹一種 VBA 方法,讓您輕鬆將 Outlook 資料夾結構複製到 Windows 資源管理器。
將 Outlook 資料夾結構複製到桌面(Windows 資源管理器)
將 Outlook 資料夾結構複製到桌面(Windows 資源管理器)
請按照以下步驟將 Outlook 資料夾結構複製到桌面或 Windows 資源管理器。
1. 在導覽窗格中,請點擊以突出顯示要複製其資料夾結構的指定資料夾,然後按下「Alt」+「F11」鍵以打開 Microsoft Visual Basic for Applications 窗口。

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

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

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

注意:資料夾中的項目,例如郵件、約會、任務等,也會被複製到硬碟中相應的資料夾中。
相關文章
如何在 Outlook 中將資料夾結構複製到新的 pst 數據文件?
最佳辦公室生產力工具
最新消息:Kutools for Outlook推出免費版本!
體驗全新的Kutools for Outlook免費版本,擁有70多項令人驚嘆的功能,永久使用!立即點擊下載!
🤖 Kutools AI :使用先進的AI技術輕鬆處理郵件,包括答覆、摘要、優化、擴展、翻譯和撰寫郵件。
📧 郵件自動化:自動回覆(適用於POP和IMAP) / 計劃發送郵件 / 發送郵件時按規則自動抄送密送 / 自動轉發(高級規則) / 自動新增問候語 / 自動將多收件人郵件拆分為個別郵件...
📨 郵件管理:撤回郵件 / 按主題和其他方式阻止詐騙郵件 / 刪除重複郵件 / 高級搜索 / 整合文件夾...
📁 附件專業版:批量保存 / 批量拆離 / 批量壓縮 / 自動保存 / 自動拆離 / 自動壓縮...
🌟 介面魔法:😊更多漂亮和酷炫的表情符号 / 當重要郵件到來時提醒您 / 最小化Outlook而不是關閉...
👍 一鍵奇蹟:帶附件全部答復 / 防止網絡釣魚郵件 / 🕘顯示發件人的時區...
👩🏼🤝👩🏻 聯絡人和日曆:從選中郵件批量新增聯絡人 / 將聯絡人組拆分為個別組 / 移除生日提醒...
立即單擊解鎖Kutools for Outlook。不要等待,立即下載並提升您的效率!

