Skip to main content
Version: v6.0.0

Set-Text-Color

Command Description​

Set the font color of the currently selected text in the opened Word document

Command Prototype​

Word.SetFontColor(objWord,sColor)

Parameter Description​

ParameterRequiredTypeDefaultDescription
objWordTrueexpressionobjWordWord document object
sColorTruestring"000000"The text color can be a color value in hexadecimal, or the English name of nine common colors can automatically be recognized : black, white, blue, green, orange, pink, violet, red and yellow

Demo​

/************************************Set text color************* **************************** 
Command prototype:
Word.SetFontColor(objWord,sColor)
Input parameters:
objWord--Word document object
sColor--text color, you can fill in the hexadecimal color value, or automatically recognize
*********************************************************************************/
Dim objWord
objWord = Word.Open('''C:\Users\Administrator\Desktop\Standardization Implementation Notes.docx''',"xw4131221","",true)
Word.SelectRow(objWord,1,2)
Word.SetFontColor(objWord,"violet")