logo elektroda
logo elektroda
X
logo elektroda

[VBA] Paste Excel Table (A1-D1 & Last Completed Row) into Email Body using Outlook Application

Darekstw 9309 6
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16726004
    Darekstw
    Level 8  
    Hello,

    I have a problem with writing a brand that would stick to the e-mail content as tables selected fragments of the table from the spreadsheet as I posted in the comment

    wants in the form of a table cells from A1 to D1 and in the second row from the last completed row from the table Ax to Dx, where x - the last filled row in the table:
    Code: VBScript
    Log in, to see the code


    How to approach the topic that it would look like the table below in the body of the email:

    [VBA] Paste Excel Table (A1-D1 & Last Completed Row) into Email Body using Outlook Application

    Thank you in advance for your help.
  • ADVERTISEMENT
  • Helpful post
    #2 16726341
    clubs
    Level 38  
    Hello
    Look for Function RangetoHTML
  • ADVERTISEMENT
  • #3 16773557
    Darekstw
    Level 8  
    I have one more question regarding the macros sending emails, how to make the email be sent back to the sender, i.e. in the CC addressee we have the email address from which the email is sent?
  • ADVERTISEMENT
  • #4 16774544
    clubs
    Level 38  
    Hello
    Check

    Code: VBScript
    Log in, to see the code
  • ADVERTISEMENT
  • #5 16775633
    Darekstw
    Level 8  
    Hello

    After adding this line and variable in the code

    Dim Poczta


    The macro will pass without error in the message of the sender not provided in DW.
  • Helpful post
    #6 16776635
    clubs
    Level 38  
    Hello
    I understand that you use this code?

    Code: VBScript
    Log in, to see the code
  • #7 16777865
    Darekstw
    Level 8  
    Ok, the code fragment shown above cleared up the situation, everything works as I wanted. Thank you, the topic is closed :)

Topic summary

The discussion revolves around a VBA macro for sending an email via Outlook that includes a specific Excel table format in the email body. The user seeks to extract data from an Excel sheet, specifically from cells A1 to D1 and the last filled row in columns A to D. A suggested solution involves using the `RangetoHTML` function to format the table correctly. Additionally, the user inquires about automatically adding the sender's email address in the CC field, which is resolved by using `Poczta.Session.CurrentUser.Address`. The final code provided successfully meets the user's requirements.
Summary generated by the language model.
ADVERTISEMENT