Click to See Complete Forum and Search --> : Copy PST structure
yak77
Dec 1st, 2003, 04:22 AM
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
RobDog888
Dec 1st, 2003, 03:22 PM
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'.
Option Explicit
Private Sub cmdCheckFolderStructure_Click()
Call CreateFolderStructure("Standard Inbox Sub-Folder1")
Call CreateFolderStructure("Standard Inbox Sub-Folder2")
Call CreateFolderStructure("Standard Inbox Sub-Folder3")
End Sub
Private Sub CreateFolderStructure(ByVal sFolderName As String)
Dim oNS As Outlook.NameSpace
Dim oInbox As Outlook.MAPIFolder
Dim oNewFolder As Outlook.MAPIFolder
Dim i As Integer
Dim bFound As Boolean
Set oNS = Application.GetNamespace("MAPI")
Set oInbox = oNS.GetDefaultFolder(olFolderInbox)
For i = 1 To oInbox.Folders.Count
If oInbox.Folders.Item(i).Name = sFolderName Then
bFound = True
Exit For
Else
bFound = False
End If
Next
If bFound = False Then
Set oNewFolder = oInbox.Folders.Add(sFolderName, olFolderInbox)
End If
End SubEnjoy :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.