Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Selecting a Message (OL 2003)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> Loungers

    Is there a way via VBA to select, highlight a message in the Inbox?

    When I loop through each of the messages in the Inbox, via a For-Each loop, I want to identify the message that Oulook VBA is currently handling so that I can check some attributes.

    I am debugging code and I would love to be able to scroll the window to get to that message.

    Any examples will be great.

    Thanks

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  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: Selecting a Message (OL 2003)

    Each Explorer has a Selection object. I can't recall ever setting it, just reading it, but it would make sense for it to be read/write. As for what index you could give it, I'll leave that to you to figure out. (There may be a MailItem.Index, but I haven't checked.)

  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: Selecting a Message (OL 2003)

    I can't see a way to highlight the item being examined in the code, but an ugly solution would be to Display it, as in

    ActiveExplorer.Selection.Item(counterindex).Displa y
    <do whatever>
    ActiveExplorer.Selection.Item(counterindex).Close
    -John ... I float in liquid gardens
    UTC -7ąDS

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

    Re: Selecting a Message (OL 2003)

    Actually, I have an alternative approach that might be useful to you for reporting data out of your code, AND ALSO for debugging.

    When I'm building a "report" out of some Outlook data, I set the text data to be reported as in (pseudocode):

    Dim strStuff as String
    <run the loop on each item
    strStuff = strStuff & & Typename(Item) &" " & Item.Subject & " " & Item.Property1 & " " & Item.Property2 &vbLf
    <loop ends
    Call OpenNewNoteItem(strStuff)

    You could also use this crude method to track the items being examined and use an OnError Go To statement to trigger the call to publish the text.

    ... and my reusable procedure is (NOT pseudocode):

    Private Function OpenNewNoteItem(Optional strText As String) As NoteItem
    Dim objNoteitem As NoteItem
    Set objNoteitem = Outlook.Application.CreateItem(OLNoteItem)
    Set OpenNewNoteItem = objNoteitem
    If Len(strText) > 0 Then
    OpenNewNoteItem.Body = strText
    OpenNewNoteItem.Display
    End If
    End Function

    The code I posted <!post=here,302441>here<!/post> to search for Attachments by name is an example.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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