跳至主要内容

Kutools for Office — 一套工具,五种功能。事半功倍。

如何将Outlook文件夹结构复制到桌面(Windows资源管理器)?

Author: Kelly Last Modified: 2025-08-22

众所周知,我们可以使用归档功能将文件夹结构复制到另一个Outlook中,但您是否知道如何将Outlook文件夹结构复制到某个特定的窗口文件夹,例如桌面?本文将介绍一种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

🚀 一键下载——获取所有 Office 插件

强烈推荐:Kutools for Office(五合一)

一键下载五个安装包Kutools for Excel、Outlook、Word、PowerPoint以及 Office Tab Pro 立即点击下载!

  • 一键便利操作:一次下载全部五个安装包。
  • 🚀 随时满足 Office任务需求:需要哪个插件随时安装即可。
  • 🧰 包含:Kutools for Excel / Kutools for Outlook / Kutools for Word / Office Tab Pro / Kutools for PowerPoint