Microsoft Outlook 10,0 Object Library

Location: C:\Program Files\Microsoft Office\OfficelO\msoutl.olb Language: Standard

Figure 9.3 - VBA automatically sets references for both the Office and Outlook object libraries.

To view or set references for Projectl

1. If the Outlook application window is active, press Alt+F11 to open the VBA Editor window.

2. On the Tools menu of the VBA Editor, select the References command.

3. Select additional object libraries to reference in your VBA project by checking the box next to the name of the object library you wish to reference in the Available References list box.

4. Click OK when you have finished selecting references.

Saving Your Outlook VBA Project

If you have written code for ThisOutlookSession or added code modules to Projectl, you will be prompted to save the project when you quit Outlook. If you answer Yes to the alert box that prompts you to save the project, you will save the project in a file named VBAProject.otm. You cannot change the name of the file in which an Outlook VBA project is saved. Unlike project files in Visual Basic, VBAProject.otm is a binary file, and you should not attempt to edit it with a text editor. You also cannot change the folder location in which VBAProject.otm is stored. VBAProject.otm is stored in the following locations depending upon the operating system you are using:

Operating System Location for VBAProject.otm

Microsoft Windows 98 and ME dnVe:\Windows\Application Data\ Microsoft\Outlook

Microsoft Wndows NT 4 dnVe:\Winnt\Profiles\ <user>\Application Data\ Microsoft\Outlook

Microsoft Wndows 2000 dnVe:\Documents and Settings\<user>\ Application Data\Microsoft\Outlook

Securing Your Outlook VBA Project

You can secure an Outlook VBA project to protect it from unauthorized changes by others. However, you should keep in mind that an Outlook VBA project lacks the same level of security that you can achieve with an Outlook COM Add-in. The compilation of a Visual Basic COM Add-in project into an ActiveX DLL protects your source code. Only one VBA project can be associated with an Outlook application. Like their predecessor Exchange Add-ins that use .ecf files, multiple COM Add-ins can run in a single Outlook session. Remember that Outlook VBA is more a personal development tool rather than a vehicle for deploying commercial or corporate Outlook Add-ins. If you want to protect your VBA code, you can prevent users from viewing the code unless they have a password to open the project for editing. Don't lose this password, or you will be prevented from viewing and editing the code for the project.

To protect an Outlook VBA project

1. If the Outlook application window is active, press Alt+F11 to open the VBA Editor window.

2. On the Tools menu of the VBA Editor, select the Projectl Properties command.

3. Check the Lock Project For Viewing check box, as shown in Figure 9-4.

4. Supply a password to allow viewing of project properties, and then confirm the password.

5. Click OK to accept the Projectl Properties. The project is not actually locked for viewing until you quit and restart Outlook.

Figure 9.4 - The Protection tab of the Project Properties dialog box lets you lock your Outlook VBA project.

Outlook VBA projects can be digitally signed with a security certificate. On the Tools menu, select Macro and then choose the Security command to set the security level for your Outlook session. If you are developing VBA code for Outlook, it is recommended that you temporarily set the security level to Low so that you don't have to bypass the Macro Warning dialog box when Outlook launches. By default, the Macro Security setting is High for Outlook 2002. If you require additional information on developing solutions with security certificates, see Chapter 13, "Distributing and Securing Applications," and Chapter 14, "Creating COM Add-lns with Visual Basic."

Was this article helpful?

0 0

Post a comment