add appointment to shared calendar RRS feed

  • Question

  • I am trying to add an appointment to a shared calendar but it just keeps popping into the default. Any suggestions please

        Dim objOutlook As Outlook.Application
        Dim objAppt As Outlook.AppointmentItem

        Dim CalendarFolder As Outlook.MAPIFolder
        Dim myRecipient As Outlook.Recipient
        Dim myNamespace As Outlook.Namespace            

        Set objOutlook = CreateObject("Outlook.Application")

        Set myNamespace = objOutlook.GetNamespace("MAPI")
        Set myRecipient = myNamespace.CreateRecipient("John Smith")

        If myRecipient.Resolved Then
           Set CalendarFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
        End If

        Set objAppt = CreateItem(olAppointmentItem)
            With objAppt
            .Start = Me.dueDate
            .Duration = 2
            .Subject = apptSubject
            .Body = ApptBody


            End With



    Wednesday, July 26, 2017 12:29 PM

All replies

  • You need to show what CreateItem is doing in your code this is most likely where the problem is occurring.  

    Thursday, July 27, 2017 7:06 AM
  • that sounds like a good place to start but I don't know what I need to do. Is there a statement that would make sure the appointment was opened in the CalendarFolder folder. I am not familiar with the vba format of this type of statement so any help would be appreciated


    Thursday, July 27, 2017 2:14 PM
  • Generally in the OOM you would add the new item your trying to create to the Items Collection of the SharedFolder if you instance what you set in the Calendar Folder variable to . eg

     Set objAppt = CalendarFolder.Items.Add("IPM.Appointment")

    Friday, July 28, 2017 6:26 AM
  • I tried your suggestion but it gives an error

    I have been looking everywhere to try and see why this does not work and I think it may be to do with the fact that the shared calendar was added from a folder invitation in exchange online(?). Do I need to set this folder differently?


    Sunday, July 30, 2017 9:45 AM
  • If you get an error what is the error ? do you have rights to create appointments in the shared folder ?
    Tuesday, August 1, 2017 1:34 AM
  • Sorry, the error image didn't load up

    Tuesday, August 1, 2017 7:30 AM
  • Hi Glen

    I have got a bit further with this and can now navigate to the shared calendars folder and look around each one but I don't know how to pick up the name. When I loop through each  objNavFolder.DisplayName just returns "Calendar". I would appreciate any help, I think that I am getting close.


        Dim oApp As Outlook.Application

        Dim oAppt As Outlook.AppointmentItem

        Dim oNamespace As Outlook.Namespace

        Dim oFolder As Outlook.Folder

        Dim oRecipient As Outlook.Recipient


        Dim objNavMod As Object

        Dim objNavGroup As Object

        Dim objExpCal  As Object

        Dim objNavFolder As Object


        Set oApp = CreateObject("outlook.application")

        Set oNamespace = oApp.GetNamespace("MAPI")

        Set oRecipient = oNamespace.CreateRecipient(diaryTxt)



        Set objExpCal = oNamespace.GetDefaultFolder(9).GetExplorer

        Set objNavMod = objExpCal.NavigationPane.Modules.GetNavigationModule(1)

        Set objNavGroup = objNavMod.NavigationGroups.GetDefaultNavigationGroup(2)

      ‘ Check round shared calendars for the one required

      For Each objNavFolder In objNavGroup.NavigationFolders

            If objNavFolder.DisplayName = “Name Check” Then

              Set oFolder = objNavFolder.Folder

            End If


     ‘ Set the folder name

               Set objAppt = oFolder.Items.Add(olAppointmentItem)

    ‘ Add the appointment

            With objAppt

            .Start = apptDate

            .Subject = apptSubject

            .Body = apptBody


            End With

    Set objEmail = Nothing

    Set objOutlook = Nothing

    Wednesday, August 9, 2017 2:41 PM
  • If you use something like and enumerate and look at all the underlying folder properties


    Thursday, August 10, 2017 1:47 AM