Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How does one programatically modify item selection

    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

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: How does one programatically modify item selec

    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.

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: How does one programatically modify item selection

    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 <!post=this VBA thread,527,947>this VBA thread<!/post>, Hans saves the day again); it helps to build the string as a separate string variable.

    Does this help?
    -John ... I float in liquid gardens
    UTC -7ąDS

  4. #4
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How does one programatically modify item selection

    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 <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Posting Permissions

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