Red Font in a Variable

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
598
Office Version
  1. 2019
Platform
  1. Windows
I am using a macro to send an email, when i create the body of the email it is pulled from a worksheet in the workbook. Its 3 lines of text, one of them being red. When the macro runs the font is not red, how can i get the macro to pull in the text and keep it red?

thanks,

VBA Code:
strBody = Worksheets("Email Body").Range("A1").Value

With mItem
.to = recip
.CC = carbonC
.Subject = "Please Review"
.Body = strBody
.Attachments.Add sFilename
.importance = 2
.display
End With

This is what strBody is pulling in,

If this email has reached you in error, please provide updated email information for this account.
PLEASE REPLY ALL

Thank you,
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Try the following instead...

VBA Code:
Worksheets("Email Body").Range("A1").Copy

With mItem
    .Display
    .to = recip
    .CC = carbonC
    .Subject = "Please Review"
    With .GetInspector.WordEditor
        .Application.Selection.Paste
    End With
    .Attachments.Add sFilename
    .importance = 2
End With

Note that the email needs to be displayed in order to reference the inspector, hence the Display method is executed first, and then the rest of the code.

Hope this helps!
 
Upvote 0
Try the following instead...

VBA Code:
Worksheets("Email Body").Range("A1").Copy

With mItem
    .Display
    .to = recip
    .CC = carbonC
    .Subject = "Please Review"
    With .GetInspector.WordEditor
        .Application.Selection.Paste
    End With
    .Attachments.Add sFilename
    .importance = 2
End With

Note that the email needs to be displayed in order to reference the inspector, hence the Display method is executed first, and then the rest of the code.

Hope this helps!
thanks, before i try it, i have it as .display right now, but want to change it to .send once i have everything the way i want it, will that change how this would work?
 
Upvote 0
Simply keep .Display as your first line of execution, and add .Send at the end after .Importance . . .
 
Upvote 0
You can store the font color as follows...

VBA Code:
    Dim theFontColor As Long
    theFontColor = Range("B9").Font.Color

However, if you have more than one font color for the characters in your cell, it would be a little more complex. One way might be use an array to store both the text and corresponding font color for each character, where each element in the array contains a two-element array that consists of the text and corresponding font color for the character.
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,458
Members
449,085
Latest member
ExcelError

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