Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Word .NET
>
Tutorial
> Set text color
The example shows you how to set run/text color.
C# example
using System; using Independentsoft.Office.Word; namespace Sample { class Program { static void Main(string[] args) { WordDocument doc = new WordDocument(); Run run = new Run(); run.AddText("Hello Word!"); run.Color = new RunContentColor("#FF0000"); Paragraph paragraph = new Paragraph(); paragraph.Add(run); doc.Body.Add(paragraph); doc.Save("c:\\test\\output.docx", true); } } }
VB example
Imports System Imports Independentsoft.Office Imports Independentsoft.Office.Word Module Module1 Sub Main(ByVal args As String()) Dim doc As WordDocument = New WordDocument Dim run As New Run() run.AddText("Hello Word!") run.Color = New RunContentColor("#FF0000") Dim paragraph As New Paragraph() paragraph.Add(run) doc.Body.Add(paragraph) doc.Save("c:\test\output.docx", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*