Create Appointment function

Tupacmoche

Registered User.
Local time
Today, 01:42
Joined
Apr 28, 2008
Messages
291
Hi

I have an Access VB Function that creates appointments it was working fine and then started to fail with the message "User-defined type not defined' but I have not changed anything and can't find anything that is not defined. Can anyone see the problem in this code?:confused:

Public Function CreateAppointment(SubjectStr As String, BodyStr As String, RequiredAttendees As String, StartTime As Date, EndTime As Date, AllDay As Boolean)
Dim OlApp As Object 'Changed on 5-23 from Dim OlApp As Outlook.Application to 'Dim OlApp As Object
Dim oItem As Object 'Add on 5-23-17
Dim Appt As Outlook.AppointmentItem

Const olMailItem As Long = 0 'Added on 5-23-17
Set OlApp = CreateObject("Outlook.Application")
Set Appt = OlApp.CreateItem(olAppointmentItem)
Appt.MeetingStatus = olMeeting

Appt.RequiredAttendees = RequiredAttendees
Appt.Subject = SubjectStr
Appt.Start = StartTime
Appt.End = EndTime
Appt.AllDayEvent = AllDay
Appt.BOdy = BodyStr


Appt.Display

Appt.Save

'Appt.Send
Set Appt = Nothing
Set OlApp = Nothing
End Function
 
but I have not changed anything and can't find anything that is not defined
Reason it has stopped working is that you have made changes - you have now removed the outlook library from references

looks like all of these are not defined

Dim Appt As Outlook.AppointmentItem
should be
Dim Appt as object

Set Appt = OlApp.CreateItem(olAppointmentItem)
need to add in
Const olAppointmentItem As Long = 1

ensure you have Option Explicit at the top of each module (just below Option Compare Database) and then click debug>compile to find any other undefined variables.
 
Yes, your correct, I did make the changes that, I documented in the code. I was having a problem with late binding so, I adjusted as indicated. I will not try your suggestions. Thanks again!
 
There is nothing wrong with them your suggestions worked perfectly.:)
 

Users who are viewing this thread

Back
Top Bottom