Please add the option.
How to copy Outlook folder structure to desktop (windows explorer)?
As you know, we can apply the Archive feature to copy folder structure to another Outlook, but do you know how to copy Outlook folder structure to a certain window folder, such as desktop? This article will introduce a VBA to copy Outlook folder structure to windows explorer easily.
Please follow below steps to copy Outlook folder structure to the desktop or windows explorer.
1. On the Navigation Pane, please click to highlight the specified folder whose folder structure you will copy, and press Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Tools > References to open the References dialog box. Then in the dialog box check the Microsoft Scripting Runtime option, and click the OK button. See screenshot:
3. Click Insert > Module, and copy and paste below VBA code into the new module window.
VBA: Copy Outlook folder structure to windows explorer
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. Press F5 key or click the Run button to run this VBA.
5. In the popping out Browse For Folder dialog box, please select the specified folder you will place the copied folder structure, and click the OK button. See screenshot:
Now go to the specified folder, you will see the folder structure is copied to the specified hard disc. See screenshot:
Note: the folder items, such as emails, appointments, tasks, etc. are also copied into corresponding folders in the hard disc.
- Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
- Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
- Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
- Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 5 months agohello, same thing. you code works great.. the only thing is that the duplicate names, more than (1), are not exported.
Please add the option.
To post as a guest, your comment is unpublished.· 6 months agoYes! the same as Ammar asked, can you modify the code so it copies every item even if it has the same name!!! this would help me a lot
To post as a guest, your comment is unpublished.· 7 months agoHello I have one question, I used the above mentioned code, but it is missing the related conversations as it has the same subject. This is created problem as the numbers of items in outlook not matching with number of items in folder. Can you please help to edit the above code so that it also paste all the items even though it has same subject ?
To post as a guest, your comment is unpublished.· 1 years agoIt works (sort of), but (a) there were more messages exported to one folder than were in the corresponding Outlook Folder and (b) there were fewer messages exported to one folder than were in the Outlook Folder and (c) (not 100% sure) I think one message went to the wrong folder.
To post as a guest, your comment is unpublished.· 1 years agoI have Outlook 15, and the macro won't replace the "/" where used in Outlook folder names. It just skips those folders. Is this a compatibility issue?
To post as a guest, your comment is unpublished.· 1 years agoBonjour,
Serait-il possible de stocker les mails dans un fichier .pst ?
D'avance merci pour vos retours.