For example, this procedure would work fine as a toolbar macro:
Sub HelloWorld()
MsgBox "Hello World!"
End Sub
But these wouldn't:
Private Sub HelloWorld()
MsgBox "Hello World!"
End Sub
Public Sub Hello(strWho)
MsgBox "Hello " & strWho
End Sub
Public Function Hello()
strWho = _
InputBox("Say hi to whom?")
MsgBox "Hello " & strWho
Hello = strWho
End Sub
To add a macro to the toolbar, choose View, Toolbars, Customize from the main Outlook menu. On the Commands tab in the Customize dialog box, select Macros from the Categories list. You'll see a list of macros on the right. Copy the desired macro to the toolbar or to an Outlook menu. Right-click the newly created toolbar button or menu command to customize the name, button, and other features.
Adjusting the Security Level
After you've written some VBA code, you might see a message when you start Outlook telling you that the macros can't run because of your security settings or asking you to authorize the macros. Outlook's macro security level determines which message you might see. You can change the security level on the Security dialog box that Figure 2 shows. From the main Outlook menu, select Tools, Macro, Security to open the dialog box.
If you want to use High security, you need to digitally sign your project, much as you might digitally sign an email message. Office 2000 includes the selfcert.exe file, which lets you create a self-signed certificate for signing projects. After you run this program and follow its prompts, you'll have a certificate that you can use to sign any VBA project. To use the self-signed certificate to sign your Outlook VBA project, choose Tools, Digital Signature in the VBA editor. If you don't see the Digital Signature command, you need to run Office Setup to install that option. For more details, read the Microsoft Developer Network (MSDN) article "How to Prevent the VBA Macro Security Warning in Microsoft Outlook 2000" (http://msdn.microsoft.com/library/techart/oldigitalsignature.htm). Note that Microsoft cautions that because no Certificate Authority (CA) backs the self-signed certificate, you should use it to sign only your personal VBA projects.
Ready to get started? Download some code samples and get going.