Thanks Thanks:  0
Likes Likes:  0
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: outlook

  1. #11
    Board Regular
    Join Date
    Jan 2017
    Posts
    282
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    Quote Originally Posted by Macropod View Post
    Did you read:
    'Note: This code requires references to Word, via Tools|References

    hello Macropod,

    Thank you for your help. I am bit of a numpty here as i canot find 'via Tools|References' i have looked in both word & outlook but I am still

    would you kindley guide me through the darkness & into light?

    KR
    Trevor 3007

  2. #12
    Moderator Macropod's Avatar
    Join Date
    Aug 2007
    Location
    Canberra, Australia
    Posts
    2,893
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    In the Outlook VBE, choose Tools|References then scroll down till you find the Microsoft Word library.
    Cheers
    Paul Edstein
    [MS MVP - Word]

  3. #13
    Board Regular
    Join Date
    Jan 2017
    Posts
    282
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    Quote Originally Posted by Macropod View Post
    In the Outlook VBE, choose Tools|References then scroll down till you find the Microsoft Word library.
    hi & good morning Macropod,

    thanks for getting back to me.

    I followed your guide & the only 'word' reference I could find is 'Microsoft word 16.0 object library ( which I ticked). I then ran the vb/macro & throw up the debug error:-

    run time error '429'
    activex component can't create object

    I choose debug & the following is highlighted in yellow:-

    Word.Selection.InsertBefore " " & olMail.Subject

    kind regards
    Trevor3007

  4. #14
    Moderator Macropod's Avatar
    Join Date
    Aug 2007
    Location
    Canberra, Australia
    Posts
    2,893
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    OK, try replacing that line with:
    wdDoc.Application.Selection.InsertBefore " " & olMail.Subject
    Cheers
    Paul Edstein
    [MS MVP - Word]

  5. #15
    Board Regular
    Join Date
    Jan 2017
    Posts
    282
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    Quote Originally Posted by Macropod View Post
    OK, try replacing that line with:
    wdDoc.Application.Selection.InsertBefore " " & olMail.Subject


    hi there Marcopod,


    great news it works a treat & thank you.


    is it possible to insert only the end bit ( WC:13/11/17) in to a particular line of the body text?

  6. #16
    Moderator Macropod's Avatar
    Join Date
    Aug 2007
    Location
    Canberra, Australia
    Posts
    2,893
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    You could try replacing:
    olMail.Subject
    with:
    Left(olMail.Subject,11)
    Cheers
    Paul Edstein
    [MS MVP - Word]

  7. #17
    Board Regular
    Join Date
    Jan 2017
    Posts
    282
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    Quote Originally Posted by Macropod View Post
    OK, try replacing that line with:
    wdDoc.Application.Selection.InsertBefore " " & olMail.Subject


    thank you Macropad,

    with a bit of tweaking in the body, I nearly got there :}.....but

    Is it possible to choose the applicable line ( IE 8 ) for the text to be place. ATM I have delete a few lines to get the VB to insert the applicable but this is a 'customers' template & therefore this cannot altered.

    many thanks in advance & your assistance has been aces.

    Kindest regards
    Trevor3007

  8. #18
    Moderator Macropod's Avatar
    Join Date
    Aug 2007
    Location
    Canberra, Australia
    Posts
    2,893
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    It would be really helpful if you'd said clearly from the outset what you wanted. As coded, the macro simply inserts the content at wherever your selection/insertion point is. In order to code the macro to insert the content at a particular location, I'd have to know exactly what that location is. It would have to be either: a fixed point in the email (saying something like 'line 8' is meaningless given what can happen when the email window is resized); or an offset from a known string. So far, you haven't given me anything I could work with. I have no idea what you mean by "I have delete a few lines to get the VB to insert the applicable".
    Last edited by Macropod; Nov 12th, 2017 at 08:10 AM.
    Cheers
    Paul Edstein
    [MS MVP - Word]

  9. #19
    Board Regular
    Join Date
    Jan 2017
    Posts
    282
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    Quote Originally Posted by Macropod View Post
    It would be really helpful if you'd said clearly from the outset what you wanted. As coded, the macro simply inserts the content at wherever your selection/insertion point is. In order to code the macro to insert the content at a particular location, I'd have to know exactly what that location is. It would have to be either: a fixed point in the email (saying something like 'line 8' is meaningless given what can happen when the email window is resized); or an offset from a known string. So far, you haven't given me anything I could work with. I have no idea what you mean by "I have delete a few lines to get the VB to insert the applicable".

    Hi Macropod,

    Yes you are correct, I should of given you the whole nine. Sorry for this oversight.
    I will endeavour to give you the full tale.

    You sorted the subject bit & when I tested it & from the odd ‘debug’ run great. However,
    I have a customer email template that get sent at the end of each working week. The subject line is always the same apart from the date. This date is to be added into the body of the email at end of the applicable text on line 8.

    The code you sorted for me ends up on line 1, but needs to go to the end of the text in line 8.
    In order for the ‘date’ to be placed correctly, I have remove a few lines from the original body
    Does this give you a better understanding?

    Again, my sincere apologies for my previous.

    KR
    Trevor3007

  10. #20
    Moderator Macropod's Avatar
    Join Date
    Aug 2007
    Location
    Canberra, Australia
    Posts
    2,893
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: outlook

    Quote Originally Posted by Trevor3007 View Post
    The subject line is always the same apart from the date. This date is to be added into the body of the email at end of the applicable text on line 8.

    The code you sorted for me ends up on line 1, but needs to go to the end of the text in line 8.
    As I already said
    Quote Originally Posted by Macropod View Post
    As coded, the macro simply inserts the content at wherever your selection/insertion point is.
    ...
    saying something like 'line 8' is meaningless given what can happen when the email window is resized
    The text inserted by the code does not only "ends up on line 1" - it ends up wherever your insertion point is when you run it. If you want it to go somewhere on what you're calling line 8, simply position the insertion point there before running the code; otherwise, you're going to have to be a lot more precise about defining the insertion position in a way that is independent of the window size.
    Cheers
    Paul Edstein
    [MS MVP - Word]

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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