+ Reply to Thread
Results 1 to 6 of 6

How to activate Outlook mail item in order to send keys

  1. #1
    Registered User
    Join Date
    02-17-2018
    Location
    The Woodlands, TX
    MS-Off Ver
    Windows 10
    Posts
    4

    How to activate Outlook mail item in order to send keys

    After creating the email, I need to paste copied range to the body of the email. Then copy another range and paste below. Problem is that if other application or folders are up, the email window opens behind something and doesn't have the focus. So the graphs in the range I am copying don't get pasted to the body. The second time I run the macro, though, it works because the email displays in front of everything. How can I force the email to have the focus every time?

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 02-18-2018 at 09:52 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,691

    Re: How to activate Outlook mail item in order to send keys

    This page explains how to directly embed an image into an email, rather than doing it with SendKeys.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    02-17-2018
    Location
    The Woodlands, TX
    MS-Off Ver
    Windows 10
    Posts
    4

    Re: How to activate Outlook mail item in order to send keys

    Thanks for the idea. The only problem saving the graphs as an image and then embedding is the loss of resolution. The graphs have a lot of detail and I want to preserve all the resolution in the original Excel file. That's why I have it copy the first 6 graphs and paste, then the next 6 and paste, since copying all 12 causes loss of resolution. Any way to force the mail item to have the focus before using send keys?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,691

    Re: How to activate Outlook mail item in order to send keys

    When I call .Display the email always has focus. I'm not sure why yours doesn't. However, try this. Omit the call to

    Please Login or Register  to view this content.
    and just before sending the keys for the paste, use

    Please Login or Register  to view this content.
    again. When I force another application to have focus, this forces the mail back to focus.

    Then set objMail to Nothing when you are all done.

  5. #5
    Registered User
    Join Date
    02-17-2018
    Location
    The Woodlands, TX
    MS-Off Ver
    Windows 10
    Posts
    4

    Re: How to activate Outlook mail item in order to send keys

    If I close out of outlook, and then re-open it, and then put a few applications over where the new email window will appear, the mail item still opens behind other things. If outlook has already been used once before running the macro, it's never an issue. I think it's fine, though. The process this is a part of is going to be automated using RPA, so any applications should be closed when the macro is run. It just seems odd that it only happens on the first instance of Outlook.

  6. #6
    Registered User
    Join Date
    02-17-2018
    Location
    The Woodlands, TX
    MS-Off Ver
    Windows 10
    Posts
    4

    Re: How to activate Outlook mail item in order to send keys

    Oddly, everything is fine now even with the original code. After a system update to my computer last night, I'm not able to reproduce the issue.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Vba--excel to send outlook mail item
    By lafleuk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2016, 07:24 AM
  2. [SOLVED] Code to send mail copying from Excel to a new outlook mail.
    By paz1987 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-11-2015, 07:54 AM
  3. Outlook 2007, Referencing mail Item created from outlook template
    By thusidie in forum Outlook Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2014, 04:33 PM
  4. Send Mail with Send Keys
    By MusicMan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-04-2014, 10:48 AM
  5. Send e-mail with image on body (.html) on e-mail manager <> outlook
    By mariotnc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2012, 09:28 PM
  6. Activate another window and send keys
    By yellowpower in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2011, 10:13 AM
  7. outlook redemtion macro cant send mail if outlook is not open ?
    By okl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-03-2010, 07:35 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1