Can't Enable Macro in Outlook 2003

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 Explicit
Option Compare Text

Sub FindFolders()
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
End If
End Sub

Function GetPath(Folder As Outlook.MAPIFolder) As String
On Error GoTo Finally
GetPath = GetPath(Folder.Parent) + "/" + Folder.Name
Exit Function
GetPath = "/" + Folder.Name
End Function

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)
End If
Dim olNewFolder As Outlook.MAPIFolder
For Each olNewFolder In CurrentFolder.Folders
ProcessFolder olNewFolder, SearchString, Note
End Sub

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.
Who is Participating?
Chris BottomleyConnect With a Mentor Commented:
Try pasting into a new module

Alt + F11 to open the macro editor

     Insert | Module to insert a code module into the project
     In the project tree select the module.
     Insert the required macro(s) into the selected module, ('Module1' or similar)

Check Security as appropriate:

In the application select Tools | Macro | Security
2003 and Earlier : Select Medium
2007 : Warnings for all Macros
Select OK

To run a macro:

Alt + F8
Select the macro
Select 'Run'

Where did you paste the code? Follow these steps

Press Alt+F11 on the outlook and that opens the Visual Basic Editor

On the left, project explorer tab, you see project1 Under that Microsoft Outlook folder and under that ThisOutlookSession.

Double click the "ThisOutlookSession" and paste the code. Just Press F5 you should be all set without making any changes
Chris BottomleyCommented:
First off where are you pasting the code ... thisOutlookSession?
Easily manage email signatures in Office 365

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!

Chris BottomleyCommented:
Note, the code is in fact three macros:

FindFolders - the real macro and two help functions:
GetPath & ProcessFolder

The editor will see them correctly as three routines hence the seperator

Chris BottomleyCommented:
IN regard to security try closing and re-opening outlook after setting the enable security.

Rooker33Connect With a Mentor Commented:
Problem #3:
Solving problem #3 is the first order of business, you need to get macros running. Setting the Macro security level to low should do the trick as Microsoft's site says "macros are automatically enabled" with the low setting ( .)  
It seems this is not working for you, but just to verify. you are using the Outlook Tools | Macro | Security menu item and you are able to select 'Low' as the macro security level?  After selecting a new level, you should make sure to shutdown Outlook and then restart for the setting to take effect. (If you haven't tried restarting and this was your problem then I do recommend setting to Medium rather than low and using your  self-signed macros.)

Problem #1:
I recommend creating a new module in the VBA Project for this macro ...
Open VBA and right click on Project1, then select "Insert | module", this should create an empty module for you to paste the above code into so that it does not interfere with any of your other existing macros.

Problem #2:
There are 3 'routines' which is probably confusing you, the actual macro to run is the first routine 'Find Folders' the other 2 routines are simply helper routines that are only meant to be called from the main macro routine, not run by you.

Chris BottomleyCommented:
Note you want one copy of the macros so move them to the new module rather than copy them.  ALso to test the start up add a macro to thisoutlooksession as:

Once it's working you can delete it.


Alt + F11 to open the macro editor

  For Applicationevent handlers:
     In the project tree select as appropriate:
      OUTLOOK      : thisOutlookSession
     In the workpane select as appropriate:
      OUTLOOK      : Application
     In the workpane select the required 'event', (i.e. 'Application_Startup").
        Insert the required code from the supplied sub into the selected subroutine.
        Replace the template inserted by the VBE with the sub as supplied

Private Sub Application_Startup()
    msgbox("MAcros Enabled")
end sub

Open in new window

GrayStricklandAuthor Commented:
NOTE:  the macro code which is listed now runs, but does not do what is expected. Troubleshooting the actual macro code is outside the scope of this thread, so I'll start a new one. The macro asks me for a search string to find a folder. When I supply that, instead of finding the folder, it opens a NOTE (memo) for editing. Weird.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.