Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Addition to this outlook macro. To remove "1" from the end of folder if exists.

Posted on 2010-01-11
Medium Priority
Last Modified: 2012-05-08

Addition to this outlook macro. To remove "1" from the end of folder if exists.
Once the below code is run...I want another check on all the sub folders and remove "1" if exists on any of the folders. So they become unique.

Question by:bsharath
  • 2
LVL 50

Accepted Solution

Dave Brett earned 2000 total points
ID: 26289975

Like this?

Note this code runs the last code plus does the next step. SO it should replace your last code


Sub 25046494()
    Dim myFolder As MAPIFolder, objFolder As MAPIFolder
    Dim intItem As Integer
    Dim itm As Object
    Dim fldr As Object
    Dim intFldr As Integer

    Set myFolder = Application.GetNamespace("mapi").PickFolder
    If Not myFolder Is Nothing Then
        For intFldr = myFolder.Folders.Count To 1 Step -1
            Set fldr = myFolder.Folders(intFldr)
            If IsNumeric(Right$(fldr.Name, 1)) Then
                On Error Resume Next
                Set objFolder = myFolder.Folders(Left(fldr.Name, Len(fldr.Name) - 1))
                On Error GoTo 0

                If Not objFolder Is Nothing Then
                    For intItem = fldr.Items.Count To 1 Step -1
                        Set itm = fldr.Items(intItem)
                        itm.Move objFolder
                    fldr.Name = Left$(fldr.Name, Len(fldr.Name) - 1)
                End If
            End If
    End If
End Sub

Open in new window

LVL 11

Author Comment

ID: 26290199
Thanks Dave...
LVL 50

Expert Comment

by:Dave Brett
ID: 26290237
thx Sharath :)

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Today as you open your Outlook, you witness an error message: “Outlook is using an old copy of your Outlook Data File…”. Probably, Outlook is accessing an old OST file.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question