How to duplicate the Outlook folder structure

Posted on 2007-10-15
Last Modified: 2010-01-19
Let's say current I have PST store my 2006 email.


Currently the PST is reach the size limit.

So I would like to create another PST for 2007 with current folder structure (they is 10 parent folder and 30 subfolder)

I don't want to copy to another PST and delete all the email to preserve the folder structure,

How to duplicate to the empty mail PST with preserve the folder structure??
Question by:alexjayaprakash
    LVL 30

    Expert Comment

    export ,then import or you could do a move
    LVL 76

    Expert Comment

    by:David Lee
    Hi, alexjayaprakash.

    I can do it with a fairly simple bi of scripting, if that's an option.  I can post the code for doing this if it is.
    LVL 3

    Author Comment

    Yes, please let me test and confirm.
    LVL 76

    Accepted Solution


    My deepest apologies for taking so long to respond.  I lost track of this question and only now discovered that I hadn't posted the code.  Here's the solution I propose.  Follow these instructions to use it.

    1.  Start Outlook.
    2.  Click Tools->Macro->Visual Basic Editor.
    3.  If not already expanded, expand Modules and click on Module1.
    4.  Copy the code below and paste it into the right-hand pane of the VB Editor.
    5.  Click the diskette icon on the toolbar to save the changes.
    6.  Close the VB Editor.
    7.  Click Tools->Macro->Security.
    8.  Change the Security Level setting to Medium.
    9.  Select the folder you want to duplicate.
    10.  Run the macro.  The code does everything for you including creating the new PST file.
    Dim olkSrcFolder As Outlook.MAPIFolder, _
        olkDestFolder As Outlook.MAPIFolder
    Sub DuplicateFolderStructure()
        Dim strDestFolder As String
        Set olkSrcFolder = Application.ActiveExplorer.CurrentFolder
        strDestFolder = InputBox("Enter a name for the new Personal Folder.", "Duplicate Folder Structure")
        If strDestFolder <> "" Then
            Session.AddStore strDestFolder & ".pst"
            Set olkDestFolder = Session.Folders.GetLast()
            CreateFolder olkSrcFolder
        End If
        Set olkNewPST = Nothing
        Set olkDestFolder = Nothing
        Set olkSrcFolder = Nothing
        MsgBox "Completed.", vbOKOnly + vbInformation, "Duplicate Folder Structure"
    End Sub
    Sub CreateFolder(olkFolder As Outlook.MAPIFolder)
        Dim olkSubFolder As Outlook.MAPIFolder
        olkDestFolder.Folders.Add olkFolder.Name
        Set olkDestFolder = olkDestFolder.Folders.Item(olkFolder.Name)
        For Each olkSubFolder In olkFolder.Folders
            CreateFolder olkSubFolder
        Set olkDestFolder = olkDestFolder.Parent
        Set olkSubFolder = Nothing
    End Sub

    Open in new window

    LVL 3

    Author Comment

    No luck..when I try to run I got error "Compile error: Statement Invalid Outside Type Block
    LVL 76

    Assisted Solution

    by:David Lee
    What line does the error occur on, or what line is highlighted by the error?

    Expert Comment

    Line 9 generates an errorcode. This can be simply solved by filling in the complete path where tot create the duplicate. Like:
    Session.AddStore ("D:\MyDocs\Oultlook\" & strDestFolder & ".pst")


    Expert Comment

    In case somebody else come around trying to find out how to do it...

    1) In File Menu click in Archive
    2) Select Archive this folder and all subfolders
    3) Select the PST with the folder structure you want to duplicate
    4) In "Archive items older than" write a date older than any email you have in that PST (for instance, Mon 1990-01-01)
    5) Checkmark on the Include items with "Do not AutoArchive" checked
    6) Browse where to save the new .PST
    7) Click OK
    8) Wait for the archiving process to finish.
    9) A new PST called "Archive Folders" will appear in the left panel. It will contain the same folder structure but no data items from the old .PST
    10) Change the name as needed (right click, properties, advanced, NAME)

    see you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Get an idea of what you should include in an email disclaimer with these Top 5 email disclaimer tips.
    Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now