0

I am trying to change the background color (only for a few words) in a Word document.

I am using DocX (https://docx.codeplex.com/SourceControl/latest#Examples/Program.cs), but I cannot find any methods/properties which allow me to do so.

Here is my code:

    var rb = new Formatting();
        rb.UnderlineColor = this.GetResultColor(stu.RespectfulBehavior);
        rb.FontColor = this.GetResultColor(stu.RespectfulBehavior);

templ.ReplaceText(PlaceHolders.RespectfulBehaviour.GetDisplayName(), "    ", newFormatting: rb);
halfer
  • 19,824
  • 17
  • 99
  • 186
Franva
  • 6,565
  • 23
  • 79
  • 144

1 Answers1

0

Looking at the DocX source code of the Formatting in class I would say that you're looking for Highlight. So if you wanted something highlighted in blue

rb.Highlight = Highlight.blue;

Edit: This seems to have been already answered in this question https://stackoverflow.com/a/30141775/2039359

Community
  • 1
  • 1
BunkerMentality
  • 1,327
  • 16
  • 21
  • yep, after hours of searching and diving into the code, I found that it's actually the highlight I am looking for... Thank you for your answer :) – Franva May 25 '15 at 11:45