Create Appointment using VBA and Custom Form

I have created a Custom Appointment Form called 'PRH Appointment' and published to Personal Forms Library.
I now wish to create new appointments via VBA utilizing this Form .... how is causing me some difficulty!
Can someone assist me in how to amend my code snippet, which simply uses the default form, to allow me to achieve my goal?

Dim olApp As Outlook.Application
            Dim olApt As AppointmentItem            
 
            Set olApp = New Outlook.Application
            Set olApt = olApp.CreateItem(olAppointmentItem)
        
            With olApt
                .Start = dteStart
                .End = dteEnd
                .Subject = strEvent
                .Location = strLocation
                .Body = strbody
                .BusyStatus = olFree
                .ReminderSet = False
                .Categories = strCat
                .Save
            End With
                    
            Set olApt = Nothing
            Set olApp = Nothing

Open in new window

PeterRHawkesAsked:
Who is Participating?
 
David LeeCommented:
Hi, PeterRHawkes.

You need to change line #5.  It is going to create a default appointment item, not your custom appointment.  Use this command sequence to create an item using your custom form

    Set olkFolder = Session.GetDefaultFolder(olFolderCalendar)
    Set olApt = olkFolder.Items.Add("IPM.Appointment.MyAppointmentFormName")

Replace "MyAppointmentFormName" with the name of your form.
0
 
PeterRHawkesAuthor Commented:
Thank you!
0
 
David LeeCommented:
You're welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.