I have over 100 folders in Outlook 2003. I have a separate folder for every active case file in my law practice, plus a few generic folders for emails that don't relate to any case. I have so many folders that sometimes it's hard to find the folder I'm looking for. For that reason I wanted to be able to SEARCH for a folder BY NAME. I found a macro on a website which supposedly will do this. The code is:
Option Compare Text
Dim SearchString As String
SearchString = InputBox("Enter a Folder name substring")
If SearchString <> "" Then
Dim Note As NoteItem
Set Note = CreateItem(olNoteItem)
ProcessFolder Session.Folders.GetFirst, SearchString, Note
Note.Width = 800
Function GetPath(Folder As Outlook.MAPIFolder) As String
On Error GoTo Finally
GetPath = GetPath(Folder.Parent) + "/" + Folder.Name
GetPath = "/" + Folder.Name
Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder, SearchString As String, Note As NoteItem)
If InStr(CurrentFolder.Name, SearchString) > 0 Then
Note.Body = Note.Body + GetPath(CurrentFolder) + Chr(10)
Dim olNewFolder As Outlook.MAPIFolder
For Each olNewFolder In CurrentFolder.Folders
ProcessFolder olNewFolder, SearchString, Note
In Outlook 2003, I went to TOOLS, MACRO, VISUAL BASIC EDITOR and pasted in this code to create the macro. This presents three problems:
1. Pasting in this code, the first two lines ("Option Explicit" and "Option Compare Text") associate themselves with the previous macro, not the one I was trying to create. I eventually just deleted these two lines.
2. The VBA editor seems to see this as three macros, not one. it inserts horizontal lines between them, as it would between separate macros.
3. IT WON'T RUN. No matter what I do, I get the error "The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros." I've tried setting macro security to "LOW" but that didn't help. I tired creating my own digital certificate using this mehod:
a. Create a digital certificate for yourself. In Windows XP: Start, All Programs, Microsoft Office Tools, Digital Certificate for VBA Projects. Follow the instructions to create a certificate.
b. Sign the Macro. In Outlook: Tools, Macro, Visual Basic Editor. In the Project Explorer, select the project you want to sign. Click Tools, Digital Signature. Click Choose, select the certificate, click OK twice. Save.
c. When you open or run the macro, you will get a security warning. Check "Always trust macros from this source."
This didn't help either. I do not get a security warning giving me the opportunity to "trust" macros from this source. It just tells me that macros are disabled.