Microsoft Office Tutorials and References
In Depth Information
Adding Contacts to Outlook
The one tricky part of the code lies in how Access stores an e-mail address.
Access doesn’t just store the e-mail address as text; it stores additional
information along with the e-address. So when VBA finds the e-mail address on
the form, you want it to read only the text component of the e-mail address
field. To direct VBA to read this property on the form, you must use the
SetFocus method of the Email text box to make sure that the control has
the focus — that is, the cursor is in that field.
The Save method of the ContactItem object saves the contact in Outlook.
The remaining code displays a message to let you know that the contact was
added to Outlook; then it cleans up the variables before the Click event
procedure ends. Figure 1-4 shows the contact in Outlook.
The code in this section and throughout this chapter is designed to show you
how to use the object libraries of other Office components. Error messages
may appear for various reasons, such as null values or typos. For more
information on handling errors in VBA, see Book VIII, Chapter 6.
Figure 1-4:
A contact
added to
from VBA.
Search JabSto ::

Custom Search