Results 1 to 2 of 2

Thread: need help to automate a copy to clipboard function

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2022
    Posts
    1

    need help to automate a copy to clipboard function

    Hi, I'm an EXTREMELY new/basic user and while I'm competent at just trying things until they work/googling until I can't see straight anymore, I thought maybe I would try actually asking for help instead of wandering around this time My exact quest is described in the following thread I found from 2013:

    https://www.vbforums.com/showthread....-Outllook-2010

    I'm looking for a quick one-click way to copy the entire body of an email, to/from/subject data lines included, to my clipboard. I'm filling in for an assistant role in our department right now (while also maintaining my own role of course) so expediting the constant stream of putting emails into our CRM is something I'm interested in. I cannot for the life of me get the macro in the thread above to work, though it is from 2013 so I wouldn't be surprised to find that everything there is completely outdated. Can anyone help point me in the right direction?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: need help to automate a copy to clipboard function

    you can easily copy all the fields in the email into a string, by appending each field, then copy the entire string into the clipboard

    where msg is a mailitem object that you have already assigned as you did not post any part of code you have tried, i have left it to you as to how you select the mailitem
    Code:
    dim mystr as string, msg as mailitem
    mystr = mystr & msg.to
    mystr = mystr & vbnewline
    mystr = mystr & msg.subject
    mystr = mystr & vbnewline
    mystr = mystr & msg.from
    mystr = mystr & vbnewline
    mystr = mystr & msg.receivedtime
    mystr = mystr & vbnewline
    mystr = mystr & msg.htmlbody
    the other thread contains suggestions /methods for copying the mystr string variable into the windows clipboard object, vba does not have a built in method to do this
    the order and selection of the fields and and any formatting can be changed to suit what end result you want
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width