Results 1 to 2 of 2

Thread: Copy PST structure

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2001
    Location
    Pune,India
    Posts
    37

    Question Copy PST structure

    Hi,
    In our company we create a new PST (Personal Folders) for each user every year(to avoid the 2 GB size problems).
    Is there a way(using VBA or any other method) to copy only the folder structure of a PST to another PST without the emails????

    The users dont want to change the PST , coz that means that they have to recreate the whole folder structure in the new PST.

    Thanks
    Smoking Kills Slowly!!!!!!!!...........So who's in HURRY????????

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    You could probably write some code to create the folder structure
    you need. Here is something to get you started.
    Add a reference to 'Microsoft Outlook x.x Object Library'.
    When you run this make sure that Outlook is running.
    This is good for either pst or exchange mailboxes.

    BTW: It sounds like you company should be using MS Exchange
    Public Folders to get around this. Then just archive the data
    every year into that years name. Ex. 'Public Data Current' and 'Public Data 2002'.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub cmdCheckFolderStructure_Click()
    4.     Call CreateFolderStructure("Standard Inbox Sub-Folder1")
    5.     Call CreateFolderStructure("Standard Inbox Sub-Folder2")
    6.     Call CreateFolderStructure("Standard Inbox Sub-Folder3")
    7. End Sub
    8.  
    9. Private Sub CreateFolderStructure(ByVal sFolderName As String)
    10.  
    11.     Dim oNS As Outlook.NameSpace
    12.     Dim oInbox As Outlook.MAPIFolder
    13.     Dim oNewFolder As Outlook.MAPIFolder
    14.     Dim i As Integer
    15.     Dim bFound As Boolean
    16.    
    17.     Set oNS = Application.GetNamespace("MAPI")
    18.     Set oInbox = oNS.GetDefaultFolder(olFolderInbox)
    19.     For i = 1 To oInbox.Folders.Count
    20.         If oInbox.Folders.Item(i).Name = sFolderName Then
    21.             bFound = True
    22.             Exit For
    23.         Else
    24.             bFound = False
    25.         End If
    26.     Next
    27.     If bFound = False Then
    28.         Set oNewFolder = oInbox.Folders.Add(sFolderName, olFolderInbox)
    29.     End If
    30.    
    31. End Sub
    Enjoy
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width