Consulting

Results 1 to 2 of 2

Thread: Call a Shared Calendar Folder

  1. #1
    VBAX Newbie
    Joined
    Oct 2018
    Posts
    1
    Location

    Call a Shared Calendar Folder

    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?

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    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
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •