Consulting

Results 1 to 2 of 2

Thread: Outlook 2010 SendKeys

  1. #1
    VBAX Newbie
    Joined
    Feb 2017
    Posts
    1
    Location

    Outlook 2010 SendKeys

    Hi,

    I have many email accounts in Outlook 2010 and am looking for a way to automate collapsing mail folders in the Folder pane which insist on opening whenever a new email arrives for that account. I use favourite folders to offset this problem, but it is still a pain to have many folders open each with many open sub-folders.

    Starting with Personal Folders at the top of the list, repetitive manual keystrokes of LEFT and DOWN have the desired result.

    However,, the equivalent macro:

    Sub CollapseFolders()
           Application.SendKeys "{LEFT}{DOWN}", True
           Application.SendKeys "{LEFT}{DOWN}", True
    End Sub
    fails with "Object does not support this property or method", whereas these versions:

    Sub CollapseFolders()
           SendKeys "{LEFT}{DOWN}", True
           SendKeys "{LEFT}{DOWN}", True
    End Sub
    
    Sub CollapseFolders()
           SendKeys "{LEFT}{DOWN}"
           SendKeys "{LEFT}{DOWN}"
    End Sub
    compile OK, but achieve nothing.

    I am aware that many internet answers suggest this task is not automatable, but it isn't obvious to me why this code should not work.

    Grateful for any hints or explanations as to why the MS documentation does not mention any relevant restrictions.

    Thanks !
    Last edited by Paul_Hossler; 02-26-2017 at 07:55 PM. Reason: Added [CODE] tags - please use the [#] icon to add and paste macro between them

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    SendKeys is famous for being buggy

    ON my PC

    Sub CollapseFolders() 
        SendKeys "{LEFT}{DOWN}", True 
        SendKeys "{LEFT}{DOWN}", True 
    End Sub
    just turns NumLock on and off (below)


    https://support.microsoft.com/en-us/...ff-numlock-key



    From the article, one GUESS might be to try something like this


    Sub CollapseFolders() 
        SendKeys "{LEFT}", True 
        DoEvents
        SendKeys "{DOWN}", True 
        DoEvents
        SendKeys "{LEFT}", True 
        DoEvents
        SendKeys "{DOWN}", True 
        DoEvents
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Tags for this Thread

Posting Permissions

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