Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting text in messages (Outlook 2000)

    G'day All:

    I've used Outlook VBA to insert some text into a message I'm editing (using "SendKeys") . The macro is triggered by a button on a toolbar.

    Sub TimeStamp()
    SendKeys " Written: " & Format(Now(), "hh:mm ddd dd mmmm yyy"), True
    End Sub

    Does anyone know how can I ensure that the text always gets placed in the message at the cursor location. Most times it does, but sometimes, (I think it is when the VBA code is called for the first time) the text gets placed in the To: field, even though the cursor is in the message text...

    Any ideas appreciated!

    Dave

  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: Inserting text in messages (Outlook 2000)

    Unfortunately, with SendKeys, there are no guarantees that it will work properly. I have cases in which I just close the message and try again rather than clean up the resulting mess.

    That said, the method I use to try to position in the Body, and this will position at the last insertion point, if any, is to send Alt+J to move the insertion point to the Subject line, and then send Tab to enter the body. Whether this might introduce as many problems as it solves must await the judgment of time.

  3. #3
    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: Inserting text in messages (Outlook 2000)

    Oh, if you don't mind losing whatever is on your clipboard, you can simplify the process using the approach in <!post=Post #63868,63868>Post #63868<!/post>.

    (Simplify is the wrong word since that one also uses SendKeys, but you could stop short of the SendKeys line and paste manually to avoid the random character dispersal problem.)

  4. #4
    New Lounger
    Join Date
    Jul 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting text in messages (Outlook 2000)

    Alt+J then Tab looks like it might work, since the Alt+J is forcing it to a known location. Good one!

    Re the clipboard approach, why would you use this rather than sending the text with SendKeys directly?

    Many thanks,

    Dave

  5. #5
    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: Inserting text in messages (Outlook 2000)

    On the clipboard idea, it would only be a useful workaround to store it in the clipboard and paste it manually. Otherwise, very wasteful compared with the direct SendKeys approach.

Posting Permissions

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