Skip to main content

Set-Text-Style

Command Description

Set the style of the currently selected text in the opened Word document

Command Prototype

Word.SetFontStyleEx(objWord,bBold,bItalic,underlineStyle)

Parameter Description

ParameterRequiredTypeDefaultDescription
objWordTrueexpressionobjWordWord document object
bBoldTruebooleanNoneWhether the text is bold; the default is false
bItalicTruebooleanNoneWhether the text is italic; the default is false
underlineStyleTrueenum0The style of underscore

Demo

/************************************Set font style************* **************************** 
Command prototype:
Word.SetFontStyleEx(objWord,bBold,bItalic,underlineStyle)
Input parameters:
objWord--Word document object
bBold--whether the text is bold
bItalic--whether the text is italic
underlineStyle--the style of the underline
*********************************************************************************/
Dim objWord
objWord = Word.Open('''C:\Users\Administrator\Desktop\Standardization Implementation Notes.docx''',"xw4131221","",true)
Word.SelectRow(objWord,3,5)
Word.SetFontStyleEx(objWord,true,true,1)