Consulting

Results 1 to 3 of 3

Thread: switch between active windows

  1. #1

    switch between active windows

    I would like some advice as to how to identify different open emails. I need to develop a script that can close a specific email (and save to drafts) not necessarily the "active window."

    Thanks all

  2. #2
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Hi Aero,
    Welcome to the board. I think we can help you with that, but I need to ask you some questions. How did the emails get opened, by user or code? (If code, please post code.) What is going to trigger the running of the script you have in mind, the user or an event (if event, which one?)
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  3. #3
    Thank you very much!

    The user opens the email and highlights a relevant section of text. A macro button is selected and the script takes over.

    It creates a new email containing the relevant text in the body (with appropriately added comments):
    Dim OL As Object
    Dim EmailItem As Object
    Set OL = CreateObject("Outlook.Application")
    Set EmailItem = OL.CreateItem(olMailItem)
    etc etc.

    the original email is now open as well as the new email (which is the active window.) Since posting my request, this is the script i have come up with to close the original email: (the script is active in the original email)

    OriginalEmail = ActiveWindow.Caption

    Call CreateEmail ' Creates the new email with content
    OpenEmail = Windows.Count ' Count the number of open emails
    For i = 1 To (OpenEmail - 1)
    ActiveWindow.Next.Activate ' cycle through open emails
    CurrentEmail = ActiveWindow.Caption ' get the email name
    If CurrentEmail = OriginalEmail Then 'there is a match
    ActiveWindow.Close (True) ' close
    GoTo TheEnd ' exit cycle
    End If
    Next i

    I dont know if this is an acceptable way to do things but it works, although there are things that cause errors.

    The added caveat is that i now need to know how to set a reminder on the original email that has been closed. Ie after 5 min activate the alert reminder. The idea is that if a response to the created email has not been received, the original email can be forwarded. i tend to forget it is there if i do not get a reminder... and we have a lot of these emails a day

    Thanks

Posting Permissions

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