Problems with automation to schedule Outlook calendar

etk

Registered User.
Local time
Today, 11:46
Joined
May 21, 2011
Messages
52
Hi,

I am having issues with the following code:

Code:
      Private Sub AddAppt_Click()          On Error GoTo AddAppt_Err          ' Save record first to be sure required fields are filled.          DoCmd.RunCommand acCmdSaveRecord          ' Exit the procedure if appointment has been added to Outlook.          If Me!AddedToOutlook = True Then             MsgBox "This appointment already added to Microsoft Outlook"             Exit Sub          ' Add a new appointment.          Else[COLOR=Red]             Dim outobj As Outlook.Application[/COLOR]             Dim outappt As Outlook.AppointmentItem             Set outobj = CreateObject("outlook.application")             Set outappt = outobj.CreateItem(olAppointmentItem)             With outappt                .Start = Me!ApptDate & " " & Me!ApptTime                .Duration = Me!ApptLength                .Subject = Me!Appt                If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes                If Not IsNull(Me!ApptLocation) Then .Location = _                   Me!ApptLocation                If Me!ApptReminder Then                   .ReminderMinutesBeforeStart = Me!ReminderMinutes                   .ReminderSet = True                End If                .Save             End With          End If          ' Release the Outlook object variable.          Set outobj = Nothing          ' Set the AddedToOutlook flag, save the record, display a message.          Me!AddedToOutlook = True          DoCmd.RunCommand acCmdSaveRecord          MsgBox "Appointment Added!"       Exit Sub       AddAppt_Err:          MsgBox "Error " & Err.Number & vbCrLf & Err.Description          Exit Sub       End Sub
The red text in the code is where the debugger puts up a fuss. The error message reads: 'User-defined type not defined'

I can't figure out why it will not recognize the Outlook.Application. What do I need for it to recognize this in the library?
 
In Tools/References you need the Outlook library checked.
 
Many thanks!
 

Users who are viewing this thread

Back
Top Bottom