ID: Q161012
The information in this article applies to:
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article shows you how to use Automation from a Microsoft Access form to start Microsoft Outlook and display a new contact screen for input. You can change just one line of code to make this example apply to a new Microsoft Outlook appointment, journal entry, mail message, note, post, or task.
For information about how to run Microsoft Schedule+ with Automation, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q147633
TITLE : ACC: How to Run Schedule+ from MS Access Using Automation
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to your version of the
"Building Applications with Microsoft Access" manual.
The following example shows how to create a form in Microsoft Access that starts Microsoft Outlook from a command button. Then, the Automation code opens a new contact screen for input in Microsoft Outlook. After you enter the contact, and save and close the contact form, the Automation code quits Microsoft Outlook and returns to the Microsoft Access form.
To run Microsoft Outlook from a Microsoft Access form, follow these steps:
1. Open the sample database Northwind.mdb.
2. Create a new form not based on any table or query in Design view:
Form: FrmOutlook
---------------------------
Caption: Outlook Form
Command button:
Name: RunOutlook
Caption: Start Outlook
OnClick: =StartOutlook()
3. On the View menu, click Code to open the form module.
4. On the Tools menu, click References.
5. Click Microsoft Outlook 8.0 Object Library in the Available References
box. If it does not appear in the list, click the Browse button and
browse for MSOutl8.olb, which is installed by default in the C:\Program
Files\Microsoft Office\Office folder.
6. Click OK to close the References dialog box.
7. Type the following procedure in the form's code module:
Public Function StartOutLook()
On Error GoTo StartOutLook_Error
Dim spObj As Object, MyItem As Object
' Create a Microsoft OutLook object.
Set spObj = CreateObject("Outlook.Application")
' Create and open new contact form for input.
' You can substitute olAppointmentItem, olJournalItem, olMailItem,
' olNoteItem, olPostItem, or olTaskItem for olContactItem.
Set MyItem = spObj.CreateItem(olContactItem)
MyItem.Display
' Quit Microsoft Outlook.
Set spObj = Nothing
Exit Function
StartOutLook_Error:
MsgBox "Error: " & Err & " " & Error
Exit Function
End Function
8. Close the module and switch the form to Form view.
9. Click the Start Outlook button. Note that Microsoft Outlook starts and
displays a new contact screen.
For more information about using Automation with Microsoft Outlook, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q160502
TITLE : ACC: Using Automation to Add Appointments to Microsoft
Outlook
For more information about using Automation to work with other programs,
search the Help Index for "Automation, overview," or ask the Microsoft
Access 97 Office Assistant.
Additional query words: OutSol OutSol97
Keywords : kbinterop IntpOlea kbfaq
Version : 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbinfo
Last Reviewed: May 4, 1999