This article was previously published under Q162371
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article shows you how to use Automation to add a task or a reminder toMicrosoft Outlook.
This article assumes that you are familiar with Visual Basic forApplications and with creating Microsoft Access applications using theprogramming tools provided with Microsoft Access. For more informationabout Visual Basic for Applications, please refer to your version of the"Building Applications with Microsoft Access" manual.
There may be times when you would like to programmatically add a task or areminder to Outlook from Microsoft Access. This article provides samplecode that enables you to create a task and play a .wav file as a reminder.
NOTE: You must point the .ReminderSoundFile property to a valid sound fileon your hard drive.
To add a task or a reminder to Microsoft Outlook, follow these steps:
Start Microsoft Access and open the sample database Northwind.mdb.
Create a module and type the following line in the Declarations section if it is not already there:
On the Tools menu, click References.
Click Microsoft Outlook 8.0 Object Library in the Available References box.
NOTE: If this object library is not available in the References list, click Browse to locate the Msoutl8.olb file, which is installed by default in the C:\Program Files\Microsoft Office\Office folder.
Type the following procedure:
Function AddOutLookTask() Dim appOutLook As Outlook.Application Dim taskOutLook As Outlook.TaskItem Set appOutLook = CreateObject("Outlook.Application") Set taskOutLook = appOutLook.CreateItem(olTaskItem) With taskOutLook .Subject = "This is the subject of my task" .Body = "This is the body of my task." .ReminderSet = True .ReminderTime = DateAdd("n", 2, Now) ' Set to remind us 2 ' minutes from now. .DueDate = DateAdd("n", 5, Now) ' Set the due date to ' 5 minutes from now. .ReminderPlaySound = True 'add the path to a .wav file on your computer. .ReminderSoundFile = "C:\Win95\media\ding.wav" .Save End With End Function
To test this function, type the following line in the Debug window,and then press ENTER:
Note that a new task is added to Microsoft Outlook.
For additional information about using Automation to add appointments to Microsoft Outlook, please see the following article in the Microsoft Knowledge Base:
160502 ACC: Using Automation to Add Appointments to Microsoft Outlook
For additional information about Automation theory and multiple examples on automating all the Office 97 products, click the article number below to view the article in the Microsoft Knowledge Base:
167223 OFF97: Microsoft Office 97 Automation Help File Available
For additional information about using Automation with Microsoft Access, search the Help Index for "Automation," or ask the Microsoft Access 97 Office Assistant.