Macro to delete all empty folders

Does someone have a macro that will go through my inbox, nested folders and 
all, and delete all empty folders?

Thank you 

6/4/2010 3:51:33 PM
outlook 87535 articles. 11 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 54

How deep are the inbox folders nested?
If you delete a folder with a nested folder the nested folder will also be 
deleted. How would you want to handle that?
With only one level of nesting i.e.
Inbox > Folder > Subfolder
the following will check the sub-folders and provide the opportunity to 
delete those that are empty of messages or sub sub-folders
It will then check the folders and provide the opportunity delete any that 
are empty of messages, and have no subfolders.

Sub RemoveEmpties()
Dim i As Long, j As Long
Dim iFolder As Folder
Dim subFolder As Folder
Dim Ask As String
For i = Application.Session.GetDefaultFolder(olFolderInbox).Folders.Count To 
1 Step -1
    Set iFolder = 
    For j = iFolder.Folders.Count To 1 Step -1
        Set subFolder = iFolder.Folders(j)
        If subFolder.Items.Count = 0 And _
            subFolder.Folders.Count = 0 Then
            Ask = MsgBox(iFolder.Name & " > " & subFolder.Name, vbYesNo, 
"Delete sub folder")
            If Ask = vbYes Then
            End If
        End If
    Next j
    If iFolder.Items.Count = 0 And _
        iFolder.Folders.Count = 0 Then
        Ask = MsgBox(iFolder.Name, vbYesNo, "Delete folder")
        If Ask = vbYes Then
        End If
    End If
Next i
End Sub

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site
Word MVP web site
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

"Dorian C. Chalom" <> wrote in message 
> Does someone have a macro that will go through my inbox, nested folders 
> and all, and delete all empty folders?
> Thank you

gmayor (48)
6/7/2010 8:53:33 AM

Similar Artilces:

Lost Permission to Public Folders
Hello All, I think I just shot my self in the foot and set the "Everyone" usr permissions to DENY on my Public Folders. Now I cannot view my Public Folders Tree within the Exchange System Manager. Is there any way I can reverse this so that I can view my public folders again. Thanks, Eric Everyone shouldnt apply if you had the administrator account as full control ... I think that the administrator supercedes the everyone in AD .. but im not quite sure "sappy" <> wrote in message news:C333E98F-BDDF-4209-9945-8C1F4876A141@micros...

Outlook calendar auto-delete
My outlook calendar is automatically sending appointments to my delete folder after 60 days which is a problem since I use that calendar to keep track of my business. I cannot figure out why it is doing this. I have read that my BB may be causing this. I called my BB provider T-Mobile and they had never heard of this problem. I changed my BB setting to keep calender entries "forever" but it still seems to be happening. I would appreciate any thoughts on what to do next... Submitted via EggHeadCafe - Software Developer Portal of Choice Featured Product / Service Review: ...

excel worksheets getting deleted in shared files on P4
Hi all I am using a workbook of 3 Mb on a network where I am using Excel 9 and MS Windows. File contains 32 worksheets for a month. Network trafic is more but th comp has 512 MB ram and uses some oracle app also. The files are sometimes shared and contains some 3d as well as arra formulas. The worksheets are getting deleted automatically when we are trying t save the file. What can be the possible reasons. Why do sheets ge deleted????? Thanx in advance Keda -- Message posted from ...

Delete messages in Imap folder
I'm looking for a rule who can move messages from Imap folder to other folder (for example "delete Item" each time i delete message. Thanks, ...

delete page within a worksheet
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Does anyone know how to delete all the extra pages of rows an columns that show up in excel within a worksheet? <br><br>I don't know if these are extra pages but when I scroll down or to the right, it just continues adding them forever. <br><br>I don't want to to set a print area. <br><br>I want to delete the extra sheets. <br><br>Phil The size of an Excel worksheet is fixed - you cannot remove the unused columns & rows. Their presence has no bear...

public folders in exchange
If you look in the KB 246504 and 179220 Thats the error messages I get. I have upgraded from Exchange 5.5 to 2003 but the problem was also in exchange 5.5 and I had the latest sp in 5.5. I cant get rid of those objects in the public folders eather in Outlook or the ESM. How to get rid of the public filders when I cant access them?? does anyone know?? Tintin >-----Original Message----- >Are they normal folders or system folders? What error do you get? Is this >in Outlook or ESM? > >"admin raw mode" - Are you trying to use the 5.5 admin? > >-- >Hope...

Is there a way to redirect only certain users folders?
I want to do a "test" redirect of folders before implementing it fully. Is there a way to just select a few users and redirect their folders in SBS 2003? Thanks, Jim Hi Jim: Folder redirection is done by the Group Policy that applies to the OU where the SBS stations are located. But it is nothing more than a forced changing of the My Documents location ot a location on the SBS (or some other place if you change the GPO). You can do the exact same thing from a user desktop. Rclick the my documents folder and change the path to some folder on the SBS or some ot...

Problem with a Distribution List in side the Public Folder
Dear All.We have Exchange 5.5 SP3 and we have made one distribution list in a contacts folder under the Public Folder.After few months Users are unable to save a new Item inside the distribution list and I get this error message:"The item could not be saved to this folder, the item has been deleted or moved or you do not have permission. Do you want to save a copy to the default folder".I made a search on Google but the problem It seams to be different from the other since the users have owner access to the folder and the folder is still there.Do you have any idea to help meThanks i...

Deleting rows with locked cells
Hello, I'm trying to find a way to overcome a "feature" I've dicovered with Excel protection. If protection is enabled, with the "delete row" checkbox active, the row cannot be deleted if there are locked cells in the row. Is there a way to defeat this "feature"? Cheers, Paul excel beginner -- paul<dot>moore@pandora<dot>be Adjust "dots" for real address Unlock those cells to start or unprotect the worksheet, do the deletion and then reprotect the worksheet? Paul Moore wrote: > > Hello, > > I'm trying to f...

Custom report folders
Is it possible to add new report folders to Crystal Enterprise on the CRM server? I have the 8.5 developer edition for CRM installed on another machine for editing. TIA Simon No it is not. Reason is that if you added a new folder all the source code for the web would have to update as well so for now you can only save to existing report folders "Simon Storr" <> wrote in message news:%23XpLaJBiDHA.2512@TK2MSFTNGP09.phx.gbl... > Is it possible to add new report folders to Crystal Enterprise on the CRM > server? I have the 8.5 developer edition ...

public folder replication!!!!!!!!!!!
Is there a while paper out there on the proper way to setup replication of public folders between 2 window2003 exchange servers. Thanks "jon" <> wrote: >Is there a while paper out there on the proper way to >setup replication of public folders between 2 window2003 >exchange servers. "proper" depends on what you want to do. Are you wanting to have a replica of every folder on both servers? If so, use the pfmigrate.wsf program on the E2K3 CD. -- Rich Matheisen MCSE+I, Exchange MVP MS Exchange FAQ at

Multiple Public Folder Stores
Is it possible to have multiple MAPI based public folder stores in Exchange 2003 all visible from an Outlook client? Thanks Alan - You can have multiple public folder stores associated with the MAPI hierarchy in the Exchange 2003 organization, but you can have only one such public folder store per server. -- Evan Dodds Microsoft Exchange Support ****** Disclaimer ****** This posting is provided "AS IS" with no warranties, and confers no rights. Note: Please do not reply to this e-mail address. It is used for newsgroup purposes only. "Alan Roberts" <alan.rob...

How can I delete all hyperlinks at once in an excel document
I have an Excel spreadsheet for our department's use which has much information that would be useful to other departments. We have hyperlinked copies of drawing data to this document which we do not want to have available to everyone. Can I copy this file to a different location and then delete all the hyperlinks at once easily? Thanks, cindylou5594 Hello Cindylou, This newsgroup is for questions concerning Microsoft Project, not Microsoft Excel. That being said, assuming your links are to documents, a find command looking for the "\" character should find an...

MAPI access to Outlook 2003 folders
This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C4C7FC.3AB2F830 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I support an application that uses 32bit MAPI to access the folders of a = local Outlook installation. The same application can also access = Outlook Express. This function accesses the folders so that the = contents of the email messages can be stored inside of a database for = future reference. Our application is able to access the Sent Items and Deleted Items = folders in Outlook clients only. If ...

When AddIn Unchecked Delete It's Tools Menu Item How?
I have an Add-In xla that has created a menu Item on the Tools Menu with the following code in the xla project. Private Sub Workbook_Open() ....... Set NewItem = Application.CommandBars(1) _ .Controls("tools").Controls.Add NewItem.Caption = MenuItemName NewItem.OnAction = MenuItemMacro NewItem.BeginGroup = True ..... end sub If the Add-In is subsequently unchecked in Tools->Add-Ins How do I delete the menu Item from the Tools Menu? Just unchecking just left the menu item on the tools menu creating an error when clicked. If Tried Private Sub Workbook_Close() Appl...

Why is Outlook 03 synchronizing folders with every send?
Running Outlook 2003 and WIN XP/SP2. With every send attempt, I get an icon and a message Outlook synchronizing folders. Send and receive times have increased tremendously. I was online with my ISP and they claim issue is on my end. I use cable modem and my web-based mail works fine using Time Warner website. This occurs on my laptop but not on my desktop. Suggestions? ...

How to synchronize Public Contact folder with local contacts?
How can I synchronize a Contact Folder in our Public Folders on our Network with my local Contacts Folder? You'll need to copy them yourself or use a utility. See for a list of utilities. -- Diane Poremsky [MVP - Outlook] Outlook Tips: Outlook & Exchange Solutions Center: Outlook Tips by email: EMO - a weekly newsletter about Outlook and Exchange: mailto:EMO-NEWSLETTER-SUBSCRIBE-REQUEST@PEACH.EASE.LSOFT.COM ...

Cannot open Public folders in Exchange System Manager
Hello, I have a problem opening public folders in Exchange system manger. The MMC hangs, when I click on "Public Folders", but these folders can be reached and opened in Outlook. The Public Folder Store is mounted. I guess it has something to do with the Exchange servers' IIS TCP port, which was 80, when Exchange was installed. Unfortunately it had to be changed later. Could that be the problem? And if so, how to I tell Exchange that the port has changed? Thanks in advance! On Mon, 18 Jul 2005 08:25:16 -0700, "TomK" <> wro...

IMAP in Outlook Express
IMAP accounts in OE have a special tab called IMAP. This tab enables by default special folders: Sent Items ("Sent Items path") and Drafts ("Drafts path"). But since there's just one checkbox, how can one enable just ONE of the special folders? Blank entries aren't accepted. That's it, that's the question. For those of you who might ask "who needs to enable just one folder?" instead of answering the question, I'll provide a real life example. Gmail's instructions clearly state: enable Drafts WITHOUT enabling Sent Items, a...

Outlook 2003 Personal Folders: Does encryption slow access to mail?
Hi, I have a 2Gb .pst file that I have built up over several years. (Never have deleted good mail or autoarchived anything). This .pst file is of course a 97-2002 version .pst file. I have reached the file size limit for this. I an error message coming up that I need to switch to the new kind of .pst file. When creating a new file there is the option for "compressible encryption" or "high encryption". With a large mail box (2Gb) would using either encryption method this significantly slow down Outlook functions such as searches through contacts and mail folders. Would one ...

Is there a way to set Folders view as the default when Outlook is first installed?
This is kind of a reverse of the question I posted the other day... I know it's really Outlook, but the questions on those forums seem rather basic, and no one bit on my other question... We're getting ready to deploy Outlook2003 to about 10,000 users. Is there a way to set the default veiw to Folder List instead of Mail when Outlook2003 is installed? Folder List is the view in which the user is able to see Public Folders.... Thanks for any ideas, Cappy On Wed, 19 Jul 2006 20:32:16 -0400, "Cappy" <cappy _ p @> wrote: >This is kind of a reverse of th...

Deleting from another user's Mailbox
Hi I have a user with permission to open another users mailbox (a service account mailbox) However, if UserA deletes an item from User B's inbox, the item is transferred to User A's deleted items folder. I have even tried dragging the item from UserB inbox to UserB deleted items folder and the item still is moved to UserA Any workaround/suggestions? Ian McCulloch Sydney, NS Canada Hy Ian, if "user A" delete an item in "user B" Mailbox, who deletes the item? I think it is "user A", so the item must be in the "Deleted items" folder of &...

LNK2005, DllMain, new, delete, and sscanf
I am running into an issue with the linker error 2005 in relation to DllMain, and the new & delete operators. I came across the following KB article at MSDN's site:;en-us;148652 This worked for one of the project to which I am importing some code - not a DLL though, it only had problems with new & delete. I went to import the code into a DLL project and then DllMain became an issue. I have tried to wits end to find a solution for this, and the only one I can find is the KB article, but the resolutions that I can figure ou...

Outlook folders help
Hi all, I I'm looking for a way to sort emails in to folders automatically without having to create the folder by hand. I recieve emails that start with a string "#23423 london" or #34890 Spain" and would like these to go to a folder that begins with that string "#?????." I have about 300 unique strings and are added at the rate of several a week. Many thanks, -Cliff <> wrote: > I recieve emails that start with a string "#23423 london" or #34890 > Spain" and would like these to go to a ...

public folder referral
i have front-end01, backend-01, backend02, public-folder01. all back-end servers have its own pub.edb and all mailbox stores point to their own respective servernames for public folder. when i try to access calendar availabililty on mailbox (back-end01) through OWA, it is prompting me to authenticate public folders on back-end02. I understand calendar availability is free/busy info. that is obtained from public folders. But my point is what is referring back-end01 to backend02, insteald of public folder server? Any input? Check if the SCHEDULE+ FREE BUSY system folder is being replicat...