Saturday, March 6, 2010

VBScript - Writing formatted text to a word file

VBScript - Writing formatted text to a word file

'Writing formatted text to a word file

Const Red = 255

Set word = CreateObject("Word.Application")

word.Visible = True
Set objDoc = word.Documents.Add()
Set objectselection = word.Selection

objectselection.Font.color = Red
objectselection.Font.Name = "Arial"
objectselection.Font.Size = "18"
objectselection.Font.underline = True
objectselection.Font.italic = True
objectselection.Font.bold = True

objectselection.TypeText "This is sample text"
objectselection.TypeParagraph()

objectselection.Font.Size = "12"
objectselection.TypeText "This is sample text-2"
objectselection.TypeParagraph()


Also See:

Opening a new word document
Opening an existing word document
Opening a new word document and writing text to it
Opening an existing word document and appending text to it at the end.
Opening an existing word document and appending text to it at the beginning.
Saving a new word file
Saving an existing word file
Formatting all content, formatting specific paragraphs or finding and formatting specific text in a word document
Inserting images/pictures to a word file
Creating table in a word document, adding text to cells, adding rows to table
Printing a word file