-
Export Outlook Custom Appointment Field
Hello,
I created a custom form to setup appointments in Outlook Calendar, and a Macro to export selected fields to CSV. I successfully managed to export predefined fields, but I am struggling to export user-defined fields.
Here the code I sue for standard fields: can you please help me to export user-defined fields?
Thank you so much!
Sub ExportAppointments()
On Error Resume Next
Dim objNS As Outlook.NameSpace
Dim objAppointments As Outlook.Items, objCalendarFolder As Outlook.MAPIFolder
Dim objAppointment As Outlook.AppointmentItem
Dim objFS As Scripting.FileSystemObject, objOutputFile As Scripting.TextStream
Set objNS = Application.GetNamespace("MAPI")
'Set objCalendarFolder = objNS.GetDefaultFolder(olFolderCalendar)
Set objCalendarFolder = Application.ActiveExplorer.CurrentFolder
Set objAppointments = objCalendarFolder.Items
Set objFS = New Scripting.FileSystemObject
Set objOutputFile = objFS.OpenTextFile("Z:\Desktop\AppointmentExports.csv", ForWriting, True)
objOutputFile.WriteLine "Subject,Location,Start,End,Cost"
For Each objAppointment In objAppointments
objOutputFile.WriteLine objAppointment.Subject & "," & objAppointment.Location & "," & objAppointment.Start & "," & objAppointment.End
Next
objOutputFile.Close
Set objNS = Nothing
Set objAppointment = Nothing
Set objAppointments = Nothing
Set objCalendarFolder = Nothing
Set objFS = Nothing
Set objOutputFile = Nothing
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules