How to Set Word Color for C#

Posted by Cc9530 under C# on 1/13/2011 | Points: 10 | Views : 2868 | Status : [Member] | Replies : 1
Why We Set Word Color?

MS Word is a software package which you can use it to write articles, reports, letters, marketing material and other documents. In all these kinds of documents, color is absolutely one of the most powerful design tools at your disposal. The reasons why we set word color:

* Color can easily help your readers recognize your article content and distinguish which part is important. It influences the way that your audience perceitive your message.
* Color can emphasize your message and help guide your audience. This selective emphasis helps reinforce significant elements in your messages.
* Color can make your word aticle more readable by helping the audience to intuitively understand the organization of your content.
* Color can make the whole article with nice look

Even viewed from a distance, color is extremely noticeable. A word document with color is much better than black-and-white words article. With the appropriate application of color, your word material will come to life.

How to Set Word Color?

All MS Word versions enable users to set color. For example, if you want to set text color, you can set/change the color of a single word, line, paragraph or even the whole article. In addition, MS Word allows you to use multiple colors within a single Word Document. Simply set word text color with 3 steps:

* Choose the text you want to set color. (Please press "Ctrl + A" if you want to set the entire document)
* Click function button "A" on the top menu font box to expand the color selection chart.
* Select your desired color from the most common colors in the list and choose a custom color by clicking "More Colors"

Besides setting word text color, MS Word also can help users to set word backgroud color, word hyperlink color, etc.

How to Use Spire.Doc Set Word Color:
Here, we suppose you have written text in a word document, and then you may use style.CharacterFormat.TextColor and paragraph.ApplyStyle methods of ParagraphStyle to set the color of the text.
Code of C#: (more: )

using System.Drawing;
using Spire.Doc;
using Spire.Doc.Documents;

namespace Encrypt
class Program
static void Main(string[] args)
//Create word document
Document document = new Document();

//Create a section
Section section = document.AddSection();

//Define ParagraphStyle class
ParagraphStyle style = new ParagraphStyle(document);
style.Name = "red";
style.CharacterFormat.TextColor = Color.Red;

//Create a paragraph
Paragraph paragraph1 = section.AddParagraph();

//Append text to paragraph1
paragraph1.AppendText("The demo demonstrates how to set word color");

//Create a second paragraph
Paragraph paragraph2 = section.AddParagraph();

//Append text to paragraph2
paragraph2.AppendText("red text");

//Append text to the text of paragraph2

//Save the file

i could be the one


Posted by: Karthikanbarasan on: 1/13/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Hi Cc9530,

Nice article with good explanation. But it will be good if you post the same in article or code section.... Forum is to ask questions and to get clarified...


Cc9530, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response