Insert a line of different colors of text into word via VBA

aellington287

New Member
Joined
Mar 7, 2016
Messages
7
I am inserting text after a bookmark in word via VBA. I want the make the second part of the line be red. Is there a way to specify in code that only part of the inserted line needs to be a different color. My code is as follows:

Code:
wdapp.ActiveDocument.Bookmarks("txtbx3").Range.InsertAfter "1-A. D. E. = " & Cells(33, 19).Value

I want the value from cell(33,19) to come into word in red. How can I do that? Do I need to just create a second bookmark?

Thanks in advance!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
You could use:
Code:
With wdapp.ActiveDocument.Bookmarks("txtbx3").Range
  .InsertAfter "1-A. D. E. = "
  .Collapse 0 'wdCollapseEnd
  .InsertAfter Cells(33, 19).Value
  .Font.ColorIndex = 6 'wdRed
End With
 
Upvote 0

Forum statistics

Threads
1,216,595
Messages
6,131,659
Members
449,662
Latest member
kismatta

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