Hello! Here is the script to create a word document and write some text in the created word document.
'Create a Word document
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
oWord.Selection.TypeText "Test document created by QTP."
oWord.ActiveDocument.SaveAs "C:\Test.doc"
oDoc.Close
oWord.Quit
We can also align the text that is to be writed in the word document. Check out the script below
'Create a Word document
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
With oWord.Selection
.EndKey 6,0
.TypeParagraph()
.Font.Size ="10"
.Font.Name = "Arial"
.Font.Color = RGB (0,100,0)
.Font.Bold = True
.Font.Underline = False
.Font.Italic = False
.TypeText "Test document created by QTP."
End With
oWord.ActiveDocument.SaveAs "C:\Test.doc"
oDoc.Close
oWord.Quit
We will see how to adding tables in to word document in another post.
'Create a Word document
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
oWord.Selection.TypeText "Test document created by QTP."
oWord.ActiveDocument.SaveAs "C:\Test.doc"
oDoc.Close
oWord.Quit
We can also align the text that is to be writed in the word document. Check out the script below
'Create a Word document
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
With oWord.Selection
.EndKey 6,0
.TypeParagraph()
.Font.Size ="10"
.Font.Name = "Arial"
.Font.Color = RGB (0,100,0)
.Font.Bold = True
.Font.Underline = False
.Font.Italic = False
.TypeText "Test document created by QTP."
End With
oWord.ActiveDocument.SaveAs "C:\Test.doc"
oDoc.Close
oWord.Quit
We will see how to adding tables in to word document in another post.
No comments:
Post a Comment