• How does one programatically modify item selection

    Home » Forums » AskWoody support » Productivity software by function » MS Outlook and email programs » How does one programatically modify item selection

    Author
    Topic
    #441770

    I have some code that operates on a MailItem to do clever stuff (extracting information and sticking it directly into my database)

    I drive it from a form that has buttons. Currently my mailitem is set as exploror.selection(1)

    What I now want to do is provide a NEXT>> and <<PREV button in a similar way to the way Access would work to get records, but , instead, navigating mailitems in the explorer.

    I simply cannot get my head around the fact that explorer.selection is a read-only field. How does one programatically modify what items are selected in an exporer window or am I simply trying to do the wrong thing. I supose I could fudge it and simply operate on the whole folder but I'm not enthusiastic.

    Thanks in advance for any light that you can shed on this

    Viewing 1 reply thread
    Author
    Replies
    • #1061561

      I think you would need to work with the entire contents of the folder. Often they are not in any order that would be useful to you, which is frustrating.

    • #1061637

      Andrew:

      > How does one programatically modify what items are selected in an explorer window or am I simply trying to do the wrong thing. I supose I could fudge it and simply operate on the whole folder but I’m not enthusiastic.

      The Explorer.Selection is read only because it is what the user has selected, it’s not meant to be modified. Though it’s a read-only collection, it has a Count Property; you can use its count to cycle through all Selected items.

      If you want to create your own “selection” within a folder, the way to do it is to select everything in the Folder and then create a subset collection using the VBA Restrict Method:

      myItems = ActiveExplorer.CurrentFolder.Items.Restrict(“[Categories] = ‘Project X'”)

      The Restrict Method is limited to one restriction at a time, but it can be a compound parameter restriction. There is also a Filter Method that I don’t recall using, but I believe it will handle more complex parameters:

      myItems = Filter(ActiveExplorer.CurrentFolder.Items, “match[, include[, compare]]”)

      As I recall, both Restrict and Filter strings parameters are a pain to get right, and take some care (see this VBA thread, Hans saves the day again); it helps to build the string as a separate string variable.

      Does this help?

      • #1061711

        Thanks both of you

        I have enough to proceed with even if its not elegant. I’m picking that I can basically operate via the explorer and correlate to selection via entryids when I have to.
        I may end up creating an order entryid cache – but I’ll play for a bit first grin

    Viewing 1 reply thread
    Reply To: How does one programatically modify item selection

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: