none
The folder created with opensharedfolder (.ics calendar local file) cannot be deleted in the same session RRS feed

  • Question

  • Hi,

    I am trying to write my first macro in Outlook VBA and I get already stopped by a stupid problem, for which I cannot find any explanation after hours of searches in many forums and documents.

    I created a sub to automatially open an .ics calendar read some items and then delete the corresponding folder. The issue is that this folder cannot be deleted in the same session where it has been created: I have to close Outlook and reopen it in order for the second macro to work.

    Reducing the macro to the strict minimum gives this:

    Sub TestIcs()
        Dim myFolder As Folder
        Set myFolder = Session.OpenSharedFolder("c:\TEMP\test.ics")
        myFolder.Delete
    End Sub

    The shared folder is created, the correct Appointments can be seen within the folder, but the delete method returns Error 0x80020009. Furthermore, it is also impossible to delete the folder from The Outlook GUI (something like "check permissions).

    BUT: If you quit Outlook and start it again, you can then delete the folder without problem, from the GUI as well as from a macro.

    Has anybody an explanation for me, and perhaps also a solution?

    Thanks
    Claude

    Friday, February 10, 2012 1:06 PM

Answers

  • Outlook keeps a reference to that folder and store and won't release it until after it closes. It's the same thing as when you open a secondary PST file in the Outlook UI, it's kept locked until after Outlook closes.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Klo10" <=?utf-8?B?S2xvMTA=?=> wrote in message news:2652cdcb-714b-43b4-a0a0-d27e2b4ca38f...

    Hi,

    I am trying to write my first macro in Outlook VBA and I get already stopped by a stupid problem, for which I cannot find any explanation after hours of searches in many forums and documents.

    I created a sub to automatially open an .ics calendar read some items and then delete the corresponding folder. The issue is that this folder cannot be deleted in the same session where it has been created: I have to close Outlook and reopen it in order for the second macro to work.

    Reducing the macro to the strict minimum gives this:

    Sub TestIcs()
        Dim myFolder As Folder
        Set myFolder = Session.OpenSharedFolder("c:\TEMP\test.ics")
        myFolder.Delete
    End Sub

    The shared folder is created, the correct Appointments can be seen within the folder, but the delete method returns Error 0x80020009. Furthermore, it is also impossible to delete the folder from The Outlook GUI (something like "check permissions).

    BUT: If you quit Outlook and start it again, you can then delete the folder without problem, from the GUI as well as from a macro.

    Has anybody an explanation for me, and perhaps also a solution?

    Thanks
    Claude


    Ken Slovak MVP - Outlook
    • Marked as answer by Klo10 Friday, February 10, 2012 5:25 PM
    Friday, February 10, 2012 4:33 PM
    Moderator

All replies

  • Outlook keeps a reference to that folder and store and won't release it until after it closes. It's the same thing as when you open a secondary PST file in the Outlook UI, it's kept locked until after Outlook closes.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Klo10" <=?utf-8?B?S2xvMTA=?=> wrote in message news:2652cdcb-714b-43b4-a0a0-d27e2b4ca38f...

    Hi,

    I am trying to write my first macro in Outlook VBA and I get already stopped by a stupid problem, for which I cannot find any explanation after hours of searches in many forums and documents.

    I created a sub to automatially open an .ics calendar read some items and then delete the corresponding folder. The issue is that this folder cannot be deleted in the same session where it has been created: I have to close Outlook and reopen it in order for the second macro to work.

    Reducing the macro to the strict minimum gives this:

    Sub TestIcs()
        Dim myFolder As Folder
        Set myFolder = Session.OpenSharedFolder("c:\TEMP\test.ics")
        myFolder.Delete
    End Sub

    The shared folder is created, the correct Appointments can be seen within the folder, but the delete method returns Error 0x80020009. Furthermore, it is also impossible to delete the folder from The Outlook GUI (something like "check permissions).

    BUT: If you quit Outlook and start it again, you can then delete the folder without problem, from the GUI as well as from a macro.

    Has anybody an explanation for me, and perhaps also a solution?

    Thanks
    Claude


    Ken Slovak MVP - Outlook
    • Marked as answer by Klo10 Friday, February 10, 2012 5:25 PM
    Friday, February 10, 2012 4:33 PM
    Moderator
  • Thanks Ken,

    If I understand you well, there is no way to let it work.

    I'll already have to close this thread without getting a solution :-(

    Friday, February 10, 2012 5:25 PM