Hi folks!
I found this code online to import an excel list of birthdays into Outlook & make them recurring, but I'm getting an error for one line.
Hoping someone can help.
I'm getting the following error for the line highlighted below:
Compile error: User-defined type not defined
Here's the code:
Sub ImportBirthdaysToCalendar()
Dim objWorksheet As Excel.Worksheet
Dim nLastRow As Integer
Dim objOutlookApp As Outlook.Application
Dim objCalendar As Outlook.Folder
Dim objBirthdayEvent As Outlook.AppointmentItem
Dim objRecurrencePattern As Outlook.RecurrencePattern
'Get the specific sheet
Set objWorksheet = ThisWorkbook.Sheets(1)
nLastRow = objWorksheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row
Set objOutlookApp = CreateObject("Outlook.Application")
Set objCalendar = objOutlookApp.Session.GetDefaultFolder(olFolderCalendar)
For nRow = 2 To nLastRow
Set objBirthdayEvent = objCalendar.Items.Add("IPM.Appointment")
'Create birthday events
With objBirthdayEvent
.Subject = objWorksheet.Range("A" & nRow) & Chr(39) & "s Birthday"
.AllDayEvent = True
.Start = objWorksheet.Range("B" & nRow)
Set objRecurrencePattern = .GetRecurrencePattern
objRecurrencePattern.RecurrenceType = olRecursYearly
.Save
End With
Next
End Sub
Any help is appreciated!
Thanks!
I found this code online to import an excel list of birthdays into Outlook & make them recurring, but I'm getting an error for one line.
Hoping someone can help.
I'm getting the following error for the line highlighted below:
Compile error: User-defined type not defined
Here's the code:
Sub ImportBirthdaysToCalendar()
Dim objWorksheet As Excel.Worksheet
Dim nLastRow As Integer
Dim objOutlookApp As Outlook.Application
Dim objCalendar As Outlook.Folder
Dim objBirthdayEvent As Outlook.AppointmentItem
Dim objRecurrencePattern As Outlook.RecurrencePattern
'Get the specific sheet
Set objWorksheet = ThisWorkbook.Sheets(1)
nLastRow = objWorksheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row
Set objOutlookApp = CreateObject("Outlook.Application")
Set objCalendar = objOutlookApp.Session.GetDefaultFolder(olFolderCalendar)
For nRow = 2 To nLastRow
Set objBirthdayEvent = objCalendar.Items.Add("IPM.Appointment")
'Create birthday events
With objBirthdayEvent
.Subject = objWorksheet.Range("A" & nRow) & Chr(39) & "s Birthday"
.AllDayEvent = True
.Start = objWorksheet.Range("B" & nRow)
Set objRecurrencePattern = .GetRecurrencePattern
objRecurrencePattern.RecurrenceType = olRecursYearly
.Save
End With
Next
End Sub
Any help is appreciated!
Thanks!