Hi All,
I know little to nothing about VBA in Outlook, but have found the code below that works pretty good except it outputs as an
ics (icalendar) file. I would like it to output as a csv file or something compatible with Excel if possible. I also need it to pull the data from a public folder calendar that has the following path in my outlook folder list: \\Public Folders - myemailaddress.gov\All Public Folders\City of Workplace\Bulletin Boards\Utilities and the name of the calendar is: Time Off Schedule. Right now it grabs the data from the default calendar. I haven't found a good way to open or use the ics file in excel. I like that this code lets you select the start and end date range to export. As always any help is greatly appreciated.
The following code was posted by Shirley Zhang at datanumen.com
To reiterate:
1. Can the output file be changed to something Excel compatible?
2. Can the data be exported from a public calendar?
Thanks,
renigar
I know little to nothing about VBA in Outlook, but have found the code below that works pretty good except it outputs as an
ics (icalendar) file. I would like it to output as a csv file or something compatible with Excel if possible. I also need it to pull the data from a public folder calendar that has the following path in my outlook folder list: \\Public Folders - myemailaddress.gov\All Public Folders\City of Workplace\Bulletin Boards\Utilities and the name of the calendar is: Time Off Schedule. Right now it grabs the data from the default calendar. I haven't found a good way to open or use the ics file in excel. I like that this code lets you select the start and end date range to export. As always any help is greatly appreciated.
The following code was posted by Shirley Zhang at datanumen.com
To reiterate:
1. Can the output file be changed to something Excel compatible?
2. Can the data be exported from a public calendar?
Code:
Sub ExportCalender_inSpecificDateRange_AsiCalendarFile()
Dim objCalendarFolder As Outlook.Folder
Dim objCalendarExporter As Outlook.CalendarSharing
Dim dStartDate As Date
Dim dEndDate As Date
Dim objShell As Object
Dim objSavingFolder As Object
Dim strSavingFolder As String
Dim striCalendarFile As String
'Get the current Calendar folder
Set objCalendarFolder = Outlook.Application.ActiveExplorer.CurrentFolder
If Not objCalendarFolder Is Nothing And objCalendarFolder.DefaultItemType = olAppointmentItem Then
Set objCalendarExporter = objCalendarFolder.GetCalendarExporter
'Enter the specific start date and end date
dStartDate = InputBox("Enter the start date, such as 7/1/2017:", "Specify Start Date")
dEndDate = InputBox("Enter the end date, such as 8/31/2017:", "Specify End Date")
If dStartDate <> #1/1/4501# And dEndDate <> #1/1/4501# Then
'Select a Windows folder for saving the exported iCalendar file
Set objShell = CreateObject("Shell.Application")
Set objSavingFolder = objShell.BrowseForFolder(0, "Select a folder:", 0, "")
strSavingFolder = objSavingFolder.self.Path
If strSavingFolder <> "" Then
striCalendarFile = strSavingFolder & "\" & "Calendar from " & Format(dStartDate, "YYYY-MM-DD") & " to " & Format(dEndDate, "YYYY-MM-DD") & ".ics"
'Export the calendar in specific date range
With objCalendarExporter
.IncludeWholeCalendar = False
.StartDate = dStartDate
.EndDate = dEndDate
.CalendarDetail = olFullDetails
.IncludeAttachments = True
.IncludePrivateDetails = False
.RestrictToWorkingHours = False
.SaveAsICal striCalendarFile
End With
MsgBox "Calendar Exported Successfully!", vbInformation
End If
Else
MsgBox "Open a calendar folder, please!", vbExclamation + vbOKOnly
End If
End If
End Sub
Thanks,
renigar