PDA

View Full Version : Call a Shared Calendar Folder



Ericka
10-17-2018, 10:59 AM
I have a calendar that I created and shared with my team. I then created VBA that will check for new items in that shared folder. It works perfectly for me. When I tried to add it to coworkers computer it failed. The line that failed is below:

This works for me:

Set olRecItems = Application.Session.Folders.Item("MyEmail at company.com").Folders.Item("Calendar").Folders.Item("Shared Folder Name")

This did not work for my coworker

Set olRecItems = Application.Session.Folders.Item("CoWorkerEmail at company.com").Folders.Item("Calendar").Folders.Item("Shared Folder Name")

OR


Application.Session.Folders.Item("CoWorkerEmail at company.com").Folders.Item("Calendar").Folders.Item("MyEmail at company.com - Shared Folder Name")

I pulled up the properties of my coworkers shared folder - Where mine said my location was //MyEmail at company.com", her location is blank. (Anywhere the code say "at" actually has the "at" sign. The forum thought I had links in my post and was not allowing it.)

Anyone have any ideas on how to fix this so the code will loop through all the items in the shared folder?

skatonni
10-29-2018, 12:52 PM
When a shared folder is not in the navigation pane there is CreateRecipient.



Private Sub readSharedCalendars()

Dim myRecipient As recipient
Dim sharedFolder As folder
Dim maxIter As Long
Dim i As Long

Dim currItem As AppointmentItem

Set myRecipient = Session.CreateRecipient("name of the owner of shared calendar")

' Always resolves an email address so useful for non-email address entry
myRecipient.Resolve
'Debug.Print myRecipient.name

If myRecipient.Resolved Then

Set sharedFolder = Session.GetSharedDefaultFolder(myRecipient, olFolderCalendar)

maxIter = sharedFolder.Items.count

If maxIter > 10 Then maxIter = 10

For i = 1 To maxIter

If sharedFolder.Items(i).Class = olAppointment Then
Set currItem = sharedFolder.Items(i)
Debug.Print currItem.subject
End If

Next

End If

End Sub