Link to home
Start Free TrialLog in
Avatar of bsohn417
bsohn417

asked on

Outlook 2003: Export Public Folder Calendar to Excel

Is there a way to export a public folder calendar to Excel?  The public folder calendars are not available when performing a File > Export within Outlook.  Thanks for any input!  
ASKER CERTIFIED SOLUTION
Avatar of Berkson Wein
Berkson Wein
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, bsohn417.

I can do this with a fairly simple bit of scripting.  Is that an option?
Avatar of bsohn417
bsohn417

ASKER

BlueDevilFan, sure.  If you have something handy I'd appreciate it.  
Is this a one time thing, or do you need to do this frequently?  If it's a one time job, a script is probably overkill...
 
@bsohn417 - Apologies, I lost track of this question.  Here's the code for doing this.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor

To export a folder

1.  Select the folder in the navigation window.
2.  Run the script.

Outlook 2000 - 2003 includes a security feature that prohibits scripts/programs from accessing Outlook fields that contain or may contain email addresses without the user's knowledge and permission.  This script is going to trigger that built-in security feature.  When it runs a dialog-box is going to pop up warning that an application is accessing your mailbox and asking for permission to continue.  Say "Yes".
Sub ExportItemsToCSV()
    Const MACRO_NAME = "Export Items to CSV"
    Dim objFSO As FileSystemObject, _
        objFile As TextStream, _
        olkFolder As Object, _
        olkItem As Object, _
        olkProp As Outlook.ItemProperty, _
        strHeader As String, _
        strValues As String, _
        strTemp As String, _
        bolHeaderWritten As Boolean
    On Error Resume Next
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Edit the file name and path on the next line.'
    Set objFile = objFSO.CreateTextFile("C:\eeTesting\Export2CSV.csv", True)
    Set olkFolder = Application.ActiveExplorer.CurrentFolder
    If olkFolder.DefaultItemType = olAppointmentItem Then
        olkFolder.Items.Sort "[Start]"
        olkFolder.Items.IncludeRecurrences = True
    End If
    For Each olkItem In olkFolder.Items
        strValues = ""
        For Each olkProp In olkItem.ItemProperties
            If (olkProp.Type <> olOutlookInternal) And (olkProp.Name <> "HTMLBody") Then
                If Not bolHeaderWritten Then
                    strHeader = strHeader & Chr(34) & olkProp.Name & Chr(34) & ","
                End If
                strTemp = olkProp.Value
                If Err.Number <> 0 Then
                    msgbox "Name: " & olkProp.Name & vbCrLf & "Type: " & olkProp.Type & vbCrLf & "Value: " & olkProp.Value, vbCritical + vbOKOnly, "Error Reading Property"
                End If
                Select Case olkProp.Name
                    Case "Body", "Subject"
                        strTemp = Replace(olkProp.Value, Chr(34), Chr(34) & Chr(34))
                End Select
                strValues = strValues & Chr(34) & strTemp & Chr(34) & ","
            End If
            DoEvents
        Next
        If Not bolHeaderWritten Then
            strHeader = Mid(strHeader, 1, Len(strHeader) - 1)
            objFile.WriteLine strHeader
            bolHeaderWritten = True
        End If
        strValues = Mid(strValues, 1, Len(strValues) - 1)
        objFile.WriteLine strValues
        DoEvents
    Next
    objFile.Close
    Set objFile = Nothing
    Set objFSO = Nothing
    Set olkContact = Nothing
    msgbox "Export complete.", vbInformation + vbOKOnly, MACRO_NAME
End Sub

Open in new window