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

x
?
Solved

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

Posted on 2010-01-11
3
Medium Priority
?
163 Views
Last Modified: 2012-05-08
Hi,

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.

Regards
Sharath
0
Comment
Question by:bsharath
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
Dave Brett earned 2000 total points
ID: 26289975
Sharath,

Like this?

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

Cheers
Dave

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
                    Next
                    fldr.Delete
                Else
                    fldr.Name = Left$(fldr.Name, Len(fldr.Name) - 1)
                End If
            End If
        Next
    End If
End Sub

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 26290199
Thanks Dave...
0
 
LVL 50

Expert Comment

by:Dave Brett
ID: 26290237
thx Sharath :)
0

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