I found the great VBA code below here on stackoverflow and when I first included it in a test workbook, it worked great. I then put the same code into the workbook I want to ultimately be using this code from and on running the module received this error:
"Compile Error: User-defined type not defined"
I haven't been able to determine why I am receiving this error. The debugger tells me the following line is the issue:
Dim oNameSpace As Namespace
Sub Create_Outlook_3()
Dim oApp As Object
Dim oNameSpace As Namespace
Dim oFolder As Object
Dim wsSrc As Worksheet
Set wsSrc = Sheets("OutlookCalExport")
' Start looping at row 3 (first two rows are for readability)
r = 3
' Do/while set condition
Do Until Trim(wsSrc.Cells(r, 1).Value) = ""
' Create the Outlook session
Set oApp = New Outlook.Application
' Set the namespace
Set oNameSpace = oApp.GetNamespace("MAPI")
' Set the folder the appointment will be created in.
Set oFolder = oNameSpace.GetFolderFromID("000000002779752072EF5A42849125C847A02A8AE2800000").Items.Add(olAppointmentItem)
' Set with block for the appointment configuration loop
With oFolder
' Set Subject line of event
.Subject = wsSrc.Cells(r, 1).Value & " " & wsSrc.Cells(r, 2).Value
' Set start time
.Start = DateValue(wsSrc.Cells(r, 3)) + wsSrc.Cells(r, 8).Value
' Set end time
.End = DateValue(wsSrc.Cells(r, 3)) + wsSrc.Cells(r, 9).Value
' Turn reminders off
.ReminderSet = False
' Set busy status to free
.BusyStatus = 0
' Have the body of the event read as the decription from the leave form in Viewpoint
.Body = wsSrc.Cells(r, 4).Value
' Save event in owners calendar
.Save
' End with block
End With
' Move to next row
r = r + 1
' Repeat do/while loop until condition is no longer valid
Loop
End Sub
I appreciate any help you all might be able to provide!