![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Is there a simple way to make a macro that walks through a PST folder
structure and deletes out all of the messages, leaving the folder structure intact? I need this because I like my file folder structure, but every few months it grows too large for my thumb drive and I need to start over with an empty PST. I would copy the current one (it's archived on another machine), then apply the macro to the copy to start with a fresh PST that has all the folders the way I like them. I know it's a "dangerous" macro, but I don't have time to manually clean out the folders and I can't think of a simple way to do this. |
Ads |
#2
|
|||
|
|||
![]()
Am Thu, 20 Jul 2006 09:19:02 -0700 schrieb Jimboluke:
You could use the follwing template to walk through all the folders. For starting at the top level youŽd call it e.g. with: LoopFolders Application.Session.Folders, True Deleting items could be done in LoopItems. For to copy the structure you could extend the template. IŽd probably give LoopFolders another argument so that thereŽs one for the source and one for the target folder. A folder would be created in LoopFolders by Set TargetFolder=TargetFolders.Add (SourceFolder.Name) YouŽll find another example for Folders.Add in the VBA help. Public Sub LoopFolders(Folders As Outlook.Folders, _ ByVal Recursive As Boolean _ ) Dim Folder As Outlook.MAPIFolder ' Loop through all folders. For Each Folder In Folders ' Loop through folder items LoopItems Folder.Items If Recursive Then ' Call this function again for going _ deeper into the object hierarchy. LoopFolders Folder.Folders, Recursive End If Next End Sub Private Sub LoopItems(Items As Outlook.Items) Dim obj As Object For Each obj In Items Select Case True Case TypeOf obj Is Outlook.MailItem ' Case TypeOf obj Is Outlook.ContactItem ' etc. End Select Next End Sub -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Is there a simple way to make a macro that walks through a PST folder structure and deletes out all of the messages, leaving the folder structure intact? I need this because I like my file folder structure, but every few months it grows too large for my thumb drive and I need to start over with an empty PST. I would copy the current one (it's archived on another machine), then apply the macro to the copy to start with a fresh PST that has all the folders the way I like them. I know it's a "dangerous" macro, but I don't have time to manually clean out the folders and I can't think of a simple way to do this. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tacking Macro | Bob_BLC | Outlook and VBA | 8 | December 5th 07 06:00 AM |
Macro | PE | Outlook - General Queries | 2 | June 25th 06 09:34 PM |
macro trouble | windandwaves | Outlook and VBA | 4 | March 21st 06 08:08 PM |
$$ looking for someone to write a macro for me | [email protected] | Outlook and VBA | 0 | March 15th 06 11:24 PM |
Two different kind of spaces | Oriolus | Outlook Express | 13 | March 9th 06 11:07 AM |