none
Find folder uber fast in Outlook Q. RRS feed

  • Question

  • In my Outlook, I have over 1,000 folders.  I want to write a macro that will find and take me to the folder as soon as possible.  The current solution, written below by Michael Bauer is really good but it takes 1 - 3 minutes to find the folder I am looking for.  This is not fast enough, is there a way to speed this process up?  BTW, running Outlook 2010.

    Respectfully,

    Jonathan Morningstar

    Private m_Folder As Outlook.MAPIFolder
    Private m_Find As String
    Private m_Wildcard As Boolean

    Public Sub FindFolder()
      Dim Name$
      Dim Folders As Outlook.Folders

      Set m_Folder = Nothing
      m_Find = ""
      m_Wildcard = False

      Name = InputBox("Find Name:", "Search Folder - ")
      If Len(Trim$(Name)) = 0 Then Exit Sub
      m_Find = Name

      m_Find = LCase$(m_Find)
      m_Find = Replace(m_Find, "%", "*")
      m_Wildcard = (InStr(m_Find, "*"))

      Set Folders = Application.Session.Folders
      LoopFolders Folders

      If Not m_Folder Is Nothing Then
        If MsgBox("Activate Folder: " & vbCrLf & m_Folder.FolderPath, vbQuestion Or vbYesNo) = vbYes Then
          Set Application.ActiveExplorer.CurrentFolder = m_Folder
        End If
      Else
        MsgBox "Not Found", vbInformation
      End If
    End Sub

    Private Sub LoopFolders(Folders As Outlook.Folders)
      Dim F As Outlook.MAPIFolder
      Dim Found As Boolean

      For Each F In Folders
        If m_Wildcard Then
          Found = (LCase$(F.Name) Like m_Find)
        Else
          Found = (LCase$(F.Name) = m_Find)
        End If

        If Found Then
          Set m_Folder = F
          Exit For
        Else
          LoopFolders F.Folders
          If Not m_Folder Is Nothing Then Exit For
        End If
      Next
    End Sub

    • Moved by Reed KimbleMVP Wednesday, May 29, 2013 10:25 PM Outlook Macro Question
    Wednesday, May 29, 2013 6:35 PM

All replies

  • You've posted to the VB.Net forums - you are using VBA inside of an Outlook Macro.  I'll move this to a more appropriate forum.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, May 29, 2013 10:25 PM
  • I guess I should add that you could also try to implement the functionality in VB.Net with an Outlook plugin, but I'm not sure that will help your performance any...

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, May 29, 2013 10:28 PM