Adding bold into a email macro

Laurence D

New Member
Joined
Sep 14, 2016
Messages
31
Hi,

I have been toying with an email macro that bulk emails clients with taylor made near identical emails in the click of a button.

I am almost done however I have encountered a minor issue whilst trying to add a bit of flair to the signature. Does anybody know how I would correct this code so that the cell contents for K2 come through into my drafts as bold?

Code:
Email_Body = ActiveSheet.Range("J2") & vbNewLine & ActiveSheet.Range("K2").Font.Bold = True

Thanks,
Laurence
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You could try setting the cell to bold before assigning it to Email_Body:
Code:
ActiveSheet.Range("K2").Font.Bold = True
Email_Body = ActiveSheet.Range("J2") & vbNewLine & ActiveSheet.Range("K2")

I dont think that will work though. I think Email_Body will only hold characters of the text (it's a string) without any formatting. You will probably need to add html tags or something. HTML Tags would look like this I think:

Email_Body = ActiveSheet.Range("J2").value & vbNewLine & <strong><b"""<strong> & ActiveSheet.Range("K2").value & "</b" &#34
 
Last edited:
Upvote 0
Sorry, to try the HTML suggestion from my last post, you would use the code below, but remove the ' single apostrophes from the html tags --- i couldn't figure out how to write it here without the post just making my text bold and removing them.

Code:
Email_Body = ActiveSheet.Range("J2").value & vbNewLine & "<'b>" & ActiveSheet.Range("K2").value & "<'/b>"
 
Last edited:
Upvote 0
Laurence

To apply formatting to an email you would need to use HTMLBody instead of Body and compose the message using appropriate HTML code.
 
Upvote 0
Thanks guys,

It can work using the .HTMLbody code but it poses new problems for me with a lack of spacing. I may just have to redesign the way I was planning to use this macro.

The "<B>" & "/B>" tactic suggested by you Odin did not work for me it just added the text at the end:
Hello <o:p></o:p>
Humpty Dumpty sat on a wall,
Humpty Dumpty had a great fall;
All the king's horses and all the king's men
Couldn't put Humpty together again. <o:p></o:p><B>Mother Goose</B>

The .HTMLBody code did work but poses new problems to the look of the final email as the html code seems to remove any and all spacing:

Hello Humpty Dumpty sat on a wall, Humpty Dumpty had a great fall; All the king's horses and all the king's men Couldn't put Humpty together again.

Mother Goose

I will keep tinkering and I am sure I will prevail!
 
Upvote 0
Right?! That was messing me up too.

If the .htmlbody is working, try concatenating in <'br> anytime you want the following text on a new line (of course removing the apostrophe)
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top