+ Reply to Thread
Results 1 to 6 of 6

Set textcolor in VBA for email containing form data

  1. #1
    Registered User
    Join Date
    07-06-2022
    Location
    Texas, USA
    MS-Off Ver
    Excel 365
    Posts
    4

    Set textcolor in VBA for email containing form data

    Hello, All. New User, first post.

    I have a user form to input data into a table which auto-generates an email that also contains the user form data. I would like to change the color of the data that comes from the user form (items in RED below) in the body of the email so the reader of said email can more easily differentiate the form data that has been input. I can find many places to show me how to change color of text strings, but these do not seem to work when applied to the objects from the form. Here is my email code:

    Please Login or Register  to view this content.
    Last edited by Edg38426; 07-07-2022 at 08:28 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Set textcolor in VBA for email containing form data

    .Body is a plain text body. You cannot apply formatting to it. You need to use HTMLBody and code the formatting in HTML. The <font> tag is deprecated in HTML5 but I think it still works in Outlook.

    BTW Why are you using On Error Resume Next? That will hide errors that you may need to know about.

    I have not tested this but here is the idea:
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    07-06-2022
    Location
    Texas, USA
    MS-Off Ver
    Excel 365
    Posts
    4

    Re: Set textcolor in VBA for email containing form data

    I didn't realize that .Body wouldn't enable that, so thank you. I implemented your code and it did change the color of the inserted data but now it is not adding a line return in between each line. Not sure why it isn't since that is the only thing that I changed.

  4. #4
    Registered User
    Join Date
    07-06-2022
    Location
    Texas, USA
    MS-Off Ver
    Excel 365
    Posts
    4

    Re: Set textcolor in VBA for email containing form data

    Will I need to add something like a <br> tag in the code now since I have switched it over to HTML?

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Set textcolor in VBA for email containing form data

    Oh, yes. Sorry, I forgot about that. vbNewLine will insert a physical newline character, which will be reflected in the generated HTML, but the rendering engine will ignore it. Add the <br> tags as desired. You can leave in the vbNewLine, but it's not really needed for an email since nobody will ever read the code.

  6. #6
    Registered User
    Join Date
    07-06-2022
    Location
    Texas, USA
    MS-Off Ver
    Excel 365
    Posts
    4

    Re: Set textcolor in VBA for email containing form data

    That works! Thank you so much for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 06-23-2020, 01:48 AM
  2. auto email form excel imputting specific row data for each email address + add graph
    By macroconfused in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2018, 01:59 AM
  3. [SOLVED] Adding data from user form to email
    By echoz in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-04-2017, 10:44 AM
  4. Change textcolor in header by using a macro
    By EliseV in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2015, 08:04 PM
  5. [SOLVED] Have more textcolor/fill buttons available for different colors
    By nelfen in forum Excel General
    Replies: 1
    Last Post: 12-16-2005, 08:50 AM
  6. IF formula for textcolor
    By Jonsson in forum Excel General
    Replies: 0
    Last Post: 03-30-2005, 07:35 AM
  7. IF Formula to test textcolor
    By Jonsson in forum Excel General
    Replies: 2
    Last Post: 03-29-2005, 10:32 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1