Range in Middle of the email body

前端 未结 2 1092
野趣味
野趣味 2020-12-22 07:13

I am working on a Code which can get the range/selection in the middle of the email body. The below code works a bit fine for me it does not captures the desired range in th

2条回答
  •  感情败类
    2020-12-22 07:38

    I'm assuming "A1:D6" is one merged ranged. You only want the top left cell in that case. If I've made an incorrect assumption let me know. .body = "Hello," & vbNewLine & vbNewLine & _ "Welcome to My World"& vbNewLine & vbNewLine & _ Activesheet.range("A1").value & _ "Thank you for your cooperation."Replacing Activesheet with something more specific would also be a good idea but depends on your worksheets.

    Edit

    Using the RangeToHTML function found here: Paste specific excel range in outlook
    Then change

     .body = "Hello," & vbNewLine & vbNewLine & _
                "Welcome to My World"& vbNewLine & vbNewLine & _
                **HERE I NEED THE CODE TO PASTE THE RANGE FROM THE EXCEL FILE IT SHOULD BE FROM "A1:D6"**
               "Thank you for your cooperation."
    

    to

    .HTMLBody = "Hello," & vbNewLine & vbNewLine & _
                "Welcome to My World"& vbNewLine & vbNewLine & _
                RangeToHTML(activesheet.range("A1:D6")) & _
               "Thank you for your cooperation."
    

提交回复
热议问题