QTP - Working with Word
'****************************************************
'Create a New Word Document
'****************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
'****************************************************
'Create a New Word Document
'****************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
'****************************************************
'****************************************************
'Create and Save a Word Document
'****************************************************
Set objWord = CreateObject("Word.Application")
objWord.Caption = "QuickTestQTP by GAReddy"
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objSelection = objWord.Selection
objSelection.Font.Name = "Arial"
objSelection.Font.Size = "18"
objSelection.TypeText "GAReddy @ QTP - Demonstrating Word Creation and Saving"
objSelection.TypeParagraph()
objSelection.Font.Size = "18"
objSelection.TypeText "GAReddy @ QTP - Demonstrating Word Creation and Saving"
objSelection.TypeParagraph()
objSelection.Font.Size = "14"
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.Font.Size = "10"
objSelection.Font.Bold = True
objSelection.TypeText "This is a sample text "
objSelection.Font.Bold = True
objSelection.TypeText "Http://QuickTestQTP.blogpsot.com"
objSelection.Font.Bold = False
objSelection.TypeText "Hey, this is GAReddy @ QuickTestQTP"
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "This is a sample text "
objSelection.Font.Bold = True
objSelection.TypeText "Http://QuickTestQTP.blogpsot.com"
objSelection.Font.Bold = False
objSelection.TypeText "Hey, this is GAReddy @ QuickTestQTP"
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "Welcome to QuickTestQTP @Http://QuickTestQTP.blogpsot.com "
objSelection.Font.Bold = False
objSelection.TypeText "GARreddy@QuickTestQTP"
objSelection.TypeParagraph()
objSelection.TypeText "Welcome to QuickTestQTP @Http://QuickTestQTP.blogpsot.com "
objSelection.Font.Bold = False
objSelection.TypeText "GARreddy@QuickTestQTP"
objSelection.TypeParagraph()
objDoc.SaveAs("C:\MyDoc.doc")
objWord.Quit
Set objWord=Nothing
objWord.Quit
Set objWord=Nothing
'****************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objRange = objDoc.Range()
objDoc.Tables.Add objRange,1,3
Set objTable = objDoc.Tables(1)
objTable.Range.Font.Size = 10
objTable.Range.Style = "Table Contemporary"
objDoc.Tables.Add objRange,1,3
Set objTable = objDoc.Tables(1)
objTable.Range.Font.Size = 10
objTable.Range.Style = "Table Contemporary"
x=2
objTable.Cell(x, 1).Range.Text = "Service Name"
objTable.Cell(x, 2).Range.text = "Display Name"
objTable.Cell(x, 3).Range.text = "State"
objTable.Cell(x, 2).Range.text = "Display Name"
objTable.Cell(x, 3).Range.text = "State"
strComputer = "."
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objItem in colItems
If x > 1 Then
objTable.Rows.Add()
End If
objTable.Cell(x, 1).Range.Text = objItem.Name
objTable.Cell(x, 2).Range.text = objItem.DisplayName
objTable.Cell(x, 3).Range.text = objItem.State
x = x + 1
Next
If x > 1 Then
objTable.Rows.Add()
End If
objTable.Cell(x, 1).Range.Text = objItem.Name
objTable.Cell(x, 2).Range.text = objItem.DisplayName
objTable.Cell(x, 3).Range.text = objItem.State
x = x + 1
Next
objDoc.SaveAs("C:\ProcessList2.doc")
objWord.Quit
Set objWord=Nothing
objWord.Quit
Set objWord=Nothing
'************************************************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objRange = objDoc.Range()
objDoc.Tables.Add objRange,1,4,1 ' 4 is no of columns on a table and 1 is the table visbile mode or else 0
Set objTable = objDoc.Tables(1)
objDoc.Tables.Add objRange,1,4,1 ' 4 is no of columns on a table and 1 is the table visbile mode or else 0
Set objTable = objDoc.Tables(1)
x=1
strComputer = "."
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objItem in colItems
If x > 1 Then
objTable.Rows.Add()
End If
objTable.Cell(x, 1).Range.Font.Bold = True
objTable.Cell(x, 1).Range.Text = objItem.Name
objTable.Cell(x, 2).Range.text = objItem.DisplayName
objTable.Cell(x, 3).Range.text = objItem.State
x = x + 1
Next
If x > 1 Then
objTable.Rows.Add()
End If
objTable.Cell(x, 1).Range.Font.Bold = True
objTable.Cell(x, 1).Range.Text = objItem.Name
objTable.Cell(x, 2).Range.text = objItem.DisplayName
objTable.Cell(x, 3).Range.text = objItem.State
x = x + 1
Next
objDoc.SaveAs("C:\ProcessList1.doc")
objWord.Quit
Set objWord=Nothing
objWord.Quit
Set objWord=Nothing
'****************************************************
'Display Service Information in a Word Document
'****************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
'Display Service Information in a Word Document
'****************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objSelection = objWord.Selection
objSelection.TypeText "Services Report"
objSelection.TypeParagraph()
objSelection.TypeText "" & Now
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeText "" & Now
objSelection.TypeParagraph()
objSelection.TypeParagraph()
strComputer = "."
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objItem in colItems
objSelection.TypeText objItem.DisplayName & " -- " & objItem.State
objSelection.TypeParagraph()
Next
objSelection.TypeText objItem.DisplayName & " -- " & objItem.State
objSelection.TypeParagraph()
Next
objDoc.SaveAs("C:\ProcessList.doc")
objWord.Quit
Set objWord=Nothing
objWord.Quit
Set objWord=Nothing
'****************************************************
'****************************************************
' Adding Formatted Text to Word Document
'****************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Font.Name = "Arial"
objSelection.Font.Size = "18"
objSelection.TypeText "GAReddy @ QuickTest QTP"
objSelection.TypeText "Http://QuickTestQTP.blogpsot.com"
objSelection.TypeParagraph()
objSelection.Font.Size = "18"
objSelection.TypeText "GAReddy @ QuickTest QTP"
objSelection.TypeText "Http://QuickTestQTP.blogpsot.com"
objSelection.TypeParagraph()
objSelection.Font.Size = "14"
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.Font.Name = "Caliber"
objSelection.Font.Size = "28"
objSelection.TypeText " QuickTest QTP > Let's learn adding formated text to Word doc"
objSelection.TypeText "Http://QuickTestQTP.blogpsot.com"
objSelection.TypeParagraph()
objSelection.Font.Size = "28"
objSelection.TypeText " QuickTest QTP > Let's learn adding formated text to Word doc"
objSelection.TypeText "Http://QuickTestQTP.blogpsot.com"
objSelection.TypeParagraph()
objSelection.Font.Size = "14"
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
'****************************************************
'****************************************************
' Adding Formatted Table to Word Document
'****************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objRange = objDoc.Range()
objDoc.Tables.Add objRange,1,3
Set objTable = objDoc.Tables(1)
x=1
strComputer = "."
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
objDoc.Tables.Add objRange,1,3
Set objTable = objDoc.Tables(1)
x=1
strComputer = "."
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objItem in colItems
If x > 1 Then
objTable.Rows.Add()
End If
objTable.Cell(x, 1).Range.Font.Bold = True
objTable.Cell(x, 1).Range.Text = objItem.Name
objTable.Cell(x, 2).Range.text = objItem.DisplayName
objTable.Cell(x, 3).Range.text = objItem.State
x = x + 1
Next
If x > 1 Then
objTable.Rows.Add()
End If
objTable.Cell(x, 1).Range.Font.Bold = True
objTable.Cell(x, 1).Range.Text = objItem.Name
objTable.Cell(x, 2).Range.text = objItem.DisplayName
objTable.Cell(x, 3).Range.text = objItem.State
x = x + 1
Next
'****************************************************
0 comments:
Post a Comment