Microsoft Office Tutorials and References
In Depth Information
Why a Macro and Not a Procedure?
Why do I call this a macro and not a procedure? It is technically a procedure, but there are three
factors, mentioned earlier in Chapter 24, that make it a macro (that is, it will be listed in the
Macros dialog box):
n It is a Sub and not a Function.
n It takes no arguments.
n It is not marked with the Private keyword.
This macro uses the InputBox statement to prompt the user for the text to search for and the
name of the destination folder. Note that the two InputBox statements are enclosed in
Do...Until loops. This is for data validation purposes — to guard against the possibility that
the user accidentally enters a blank string. The Len() function returns the length of a string
(number of characters it contains), and the loops continue prompting the user until a non-empty
string is entered.
Adding the Code to Your Outlook Project
The steps required to add this code to your Outlook installation are simple:
In Outlook, press Alt+F11 to open the VBA Editor.
In the Project Explorer, double-click Module1 to open it.
If there is any code in the module, move the editing cursor to the end of the module.
Copy the code for the macro MoveMessages() and the procedures FindFolder()
and MoveMessagesBySubject() and paste them into the module.
Click the Save button on the VBA Editor’s toolbar.
After you perform these steps, the macro MoveMessages will be listed in the Macros dialog box
from where you can run it (see Figure 25.1).
Search JabSto ::

Custom Search