VBA - Download shared calendar from Outlook.

BenGee

Board Regular
Joined
Mar 5, 2016
Messages
196
Hi - I have the below code which successfully downloads my own calendar from Outlook, however, is there a way to tweak this to specify a particular calendar. This calendar is a shared calendar called "Team Calendar".


Thanks in advance

VBA Code:
Sub Button1_Click()

    Dim olApp As Object
    Dim olNS As Object
    Dim olFolder As Object
    Dim olApt As Object
    Dim NextRow As Long
    Start1 = ActiveSheet.Range("A1")
    End1 = ActiveSheet.Range("B1")
     
    Set olApp = CreateObject("Outlook.Application")
     
    Set olNS = olApp.GetNamespace("MAPI")
     
    Set olFolder = olNS.GetDefaultFolder(9) 'olFolderCalendar
     
    Worksheets("Data").Range("A1:D1").Value = Array("Subject", "Start", "End", "Location")
     
    NextRow = 2
     
    For Each olApt In olFolder.Items
        'If olApt.Start >= Start1 And olApt.End <= End1 Then
        Worksheets("Data").Cells(NextRow, "A").Value = olApt.Subject
        Worksheets("Data").Cells(NextRow, "B").Value = olApt.Start
        Worksheets("Data").Cells(NextRow, "C").Value = olApt.End
        Worksheets("Data").Cells(NextRow, "D").Value = olApt.Location
        NextRow = NextRow + 1
        'End If
    Next olApt
     
    Set olApt = Nothing
    Set olFolder = Nothing
    Set olNS = Nothing
    Set olApp = Nothing
     
    Worksheets("Data").Columns.AutoFit

End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top