none
Outlook 2016 problem when getting GetRecurrencePattern().RecurrenceType while Reading Pane is open RRS feed

  • Question

  • Create a recurrent task and close it. Make sure the Reading pane is visible - say, you can choose the Today view. Select the task item and execute the following VBA macro (put it in a standard module in the VBA IDE):

    Public Sub ExplorerJob()
    Dim anItem As Outlook.TaskItem
    Set anItem = Application.ActiveExplorer().Selection.Item(1)
    Debug.Print anItem.GetRecurrencePattern().RecurrenceType
    End Sub

    While in the VBA IDE, open the Immediate window to see the value the macro prints. Note the value. In the Outlook UI, you may create a button calling the macro on the QAT.

    Now, when the task is selected, open it and change the recurrence pattern; specifically, change the recurrence type: choose between Daily, Weekly, Monthly, or Yearly. Press the Save & Close button. Now call the macro above. You'll find that the value it prints doesn't change. Change the recurrence type once again and let the macro print the recurrence type: it doesn't change.

    I use Outlook 2016 32bit build 16.0.7426.1015. I can also reproduce the issue in Outlook 2016 64bit.

    I can provide extra info if required.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Wednesday, November 23, 2016 11:09 AM

Answers

  • Thank you, Eugene.

    I also think the Reading Pane is the cause of the issue. In the COM add-in which showed the issue we were able to to bypass this issue by deselect the selected item via Explorer.ClearSelection (or Explorer.RemoveFromSelection). Si-i-i-i-gh.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    • Marked as answer by Andrei Smolin Friday, November 25, 2016 2:40 PM
    Friday, November 25, 2016 2:40 PM

All replies

  • Hello Andrei,

    I bielive Outlook keeps a reference to the object shown on the reading pane. Have you tried switching to another folder or item? Do you get correct results in that case?

    The GetRecurrencePattern method of the AppointmentItem class has the following description:

    When you work with recurring appointment items, you should release any prior references, obtain new references to the recurring appointment item before you access or modify the item, and release these references as soon as you are finished and have saved the changes. This practice applies to the recurring AppointmentItem object, and any Exception or RecurrencePattern object. To release a reference in Visual Basic for Applications (VBA) or Visual Basic, set that existing object to Nothing. In C#, explicitly release the memory for that object. For a code example, see the topic for the AppointmentItem object.

    Note that even after you release your reference and attempt to obtain a new reference, if there is still an active reference, held by another add-in or Outlook, to one of the above objects, your new reference will still point to an out-of-date copy of the object. Therefore, it is important that you release your references as soon as you are finished with the recurring appointment.

    P.S. I have already observed such things in Outlook when dealing with recurrence objects. 


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Proposed as answer by Eugene Astafiev Saturday, November 26, 2016 12:00 PM
    Wednesday, November 23, 2016 11:55 AM
  • Thank you, Eugene.

    I also think the Reading Pane is the cause of the issue. In the COM add-in which showed the issue we were able to to bypass this issue by deselect the selected item via Explorer.ClearSelection (or Explorer.RemoveFromSelection). Si-i-i-i-gh.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    • Marked as answer by Andrei Smolin Friday, November 25, 2016 2:40 PM
    Friday, November 25, 2016 2:40 PM
  • You are welcome, Andrei. 

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Friday, November 25, 2016 7:39 PM