|
-
Dec 1st, 2003, 05:22 AM
#1
Thread Starter
Member
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????????
-
Dec 1st, 2003, 04:22 PM
#2
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:
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 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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|