'''''''''''''''''''''''''''''''''''''''''''''''
''' Code tested with Office 2000!
'''''''''''''''''''''''''''''''''''''''''''''''
''' Export "Calendar" folder content (now -
''' end of next month) to *.txt file
'''
''' Create OL button:
'''
''' 1. View>Toolbars>Customize...>Toolbars>New
''' 2. Enter a name for toolbar
''' 3. Click "Commands" tab
''' 4. Select "Macros" in "Categories"
''' 5. Drag "Project1.ExportCalendar onto button
''' 6. Optional: Modify Selection
'''
'''''''''''''''''''''''''''''''''''''''''''''''
Sub ExportCalendar()
On Error GoTo Err_ExportCalendar
Dim molNamespace As Outlook.NameSpace, molCalendar As Outlook.MAPIFolder, molItem As Outlook.AppointmentItem
Dim strOutput As String
Set molNamespace = Application.GetNamespace("MAPI")
Set molCalendar = molNamespace.GetDefaultFolder(olFolderCalendar)
strOutput = "C:\OL_CalendarItemsTest" & Format(Date, "mmddyy") & ".txt"
Open strOutput For Output As #1
Print #1, "StartDate,StartTime,EndDate,EndTime,EntryID,Subject,IsRecurring,RecurrenceState,ReminderSet,AllDayEvent,BusyStatus,Body,Category" '' Print header
For Each molItem In molCalendar.Items
If molItem.Start >= Now And molItem.Start <= DateSerial(Year(Date), Month(Date) + 2, 0) Then
Print #1, Format(molItem.Start, "Short Date") & "," & Format(molItem.Start, "Short Time") & "," & _
Format(molItem.End, "Short Date") & "," & Format(molItem.End, "Short Time") & "," & _
molItem.EntryID & "," & molItem.Subject & "," & _
molItem.IsRecurring & "," & molItem.RecurrenceState & "," & molItem.ReminderSet & "," & _
molItem.AllDayEvent & "," & _
molItem.BusyStatus & "," & molItem.Body & "," & molItem.Categories
End If
Next
Exit_ExportCalendar:
Close #1
Set molNamespace = Nothing
Set molCalendar = Nothing
Exit Sub
Err_ExportCalendar:
Debug.Print Err.Number, Err.Description
Resume Next
End Sub