469,138 Members | 1,343 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,138 developers. It's quick & easy.

Outlook.Application "User-defined type not defined"

135 100+
Hi,

I am currently using this code I found on the internet to send an appointment to Outlook:
Expand|Select|Wrap|Line Numbers
  1. orm_frmAppointments!ApptDate = [Form_Maintenance Subform3]![Next Maintenance]
  2. 'Form_frmAppointments!ApptTime = Me![Sample Run Time]
  3. Form_frmAppointments!Appt = "BacT" & " " & Me![Combo100] & " " & "Remove from Incubator at " & Me![Sample Run Time] & " " & Me![Sample Run Date] + 1
  4. Form_frmAppointments!ApptReminder = True
  5.  
  6.  
  7.  
  8. ' Save record first to be sure required fields are filled.
  9. DoCmd.RunCommand acCmdSaveRecord
  10. ' Exit the procedure if appointment has been added to Outlook.
  11. 'If Form_frmAppointments!AddedToOutlook = True Then
  12. If Me!Outlook = True Then
  13. MsgBox "This appointment has already been added to Microsoft Outlook"
  14. Exit Sub
  15. ' Add a new appointment.
  16. Else
  17. Dim outobj As Outlook.Application
  18. Dim outappt As Outlook.AppointmentItem
  19. Set outobj = CreateObject("outlook.application")
  20. Set outappt = outobj.CreateItem(olAppointmentItem)
  21. With outappt
  22. .Start = Form_frmAppointments!ApptDate & " " & Form_frmAppointments!ApptTime
  23. .Duration = Form_frmAppointments!ApptLength
  24. .Subject = Form_frmAppointments!Appt
  25. .Categories = "Important"
  26. If Not IsNull(Form_frmAppointments!ApptNotes) Then .Body = Form_frmAppointments!ApptNotes
  27. If Not IsNull(Form_frmAppointments!ApptLocation) Then .Location = _
  28. Form_frmAppointments!ApptLocation
  29. If Form_frmAppointments!ApptReminder Then
  30. .ReminderMinutesBeforeStart = Form_frmAppointments!ReminderMinutes
  31. .ReminderSet = True
  32. End If
  33. .Save
  34. End With
  35. End If
  36. ' Release the Outlook object variable.
  37. Set outobj = Nothing
  38. ' Set the AddedToOutlook flag, save the record, display a message.
  39. Form_frmAppointments!AddedToOutlook = True
  40. Me!Outlook = True
  41. DoCmd.RunCommand acCmdSaveRecord
  42. MsgBox "Appointment Added!"
  43. Exit Sub
  44. AddAppt_Err:
  45. MsgBox "Error " & Err.Number & vbCrLf & Err.Description
  46. Exit Sub 
I have copied the code to another database project I am working on. In this new database the code is giving an error and I don't know why. The error takes place on line #17. I get the "User-defined type not defined" error. This code works great in my other database so I am wondering if there is something else I need to do that I just can't remember to get it to work right in the new database. Any ideas?
Oct 24 '10 #1
1 5177
MyWaterloo
135 100+
Never mind. I didn't have a reference set to the Microsoft Outlook Object Library. I thought I did but guess not.
Oct 24 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Frederick Noronha \(FN\) | last post: by
reply views Thread by =?Utf-8?B?SkhhbGV5?= | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.