SlideShare a Scribd company logo
1 of 6
For more QTP Realtime Scripts, visit www.ramupalanki.com

                             MS Excel Scripts

'''Script to create a new excel file , write data

'''save the file with read and write protected
'''''pwd1 is for read protected pwd2 is for write protected

Set xl=CreateObject("Excel.Application")
Set wb=xl.Workbooks.Add
xl.DisplayAlerts=False
Set ws=wb.Worksheets("sheet1")
ws.cells(1,1)=100
ws.cells(1,2)=200
wb.Saveas "e:data2.xls",,"pwd1","pwd2"
wb.Close
Set xl=nothing


'''Script to open excel file ,which is read and write protected write data
'''''pwd1 is for read protected pwd2 is for write protected

Set xl=CreateObject("Excel.Application")
Set wb=xl.Workbooks.Open("e:data2.xls",0,False,5,"pwd1","pwd2")
xl.DisplayAlerts=False
Set ws=wb.Worksheets("sheet1")
ws.cells(1,2)="hello"
ws.cells(2,2)="new data"
wb.Save
wb.Close
Set xl=nothing

''Script to get the list of links in Google and do spell check
=================================================
dim d
set mw=CreateObject("Word.Application")
set d=Description.Create
d("micclass").value="Link"
set a=Browser("Google").page("Google").childobjects(d)
for i=0 to a.count-1
mw.WordBasic.filenew
s=a(i).getROProperty("innertext")
mw.WordBasic.insert s
if mw.ActiveDocument.Spellingerrors.count>0 then

www.ramupalanki.com
For more QTP Realtime Scripts, visit www.ramupalanki.com

Reporter.ReportEvent 1,"Spelling","spelling error :"&s
end if
mw.ActiveDocument.Close(False)
next
mw.quit
set mw=nothing
=========================================
''''Script to check ON the checkboxes in yahoo mail inbox
=========================================
Dim d
Set d=Description.Create
d("micclass").value="WebCheckBox"
Set c=Browser("Inbox (17) - Yahoo! Mail").Page("Inbox (17) - Yahoo!
Mail").ChildObjects(d)
For i=1 to 10
c(i).set "ON"
Next
========================================
'''script to select a mail having subject 'hi' or 'HI'
========================================
n=Browser("yahoo").Page("yahoo").WebTable("Inbox").RowCount
For i=2 to n
s=Browser("yahoo").Page("yahoo").WebTable("Inbox").GetCellData(i,7)
If lcase(trim(s))="hi" Then
Browser("yahoo").Page("yahoo").WebCheckBox("index:="&i-1).set "ON"
End If
Next
========================================
'''''Function to send a mail
========================================
Function SendMail(SendTo, Subject, Body, Attachment)
Set otl=CreateObject("Outlook.Application")
Set m=otl.CreateItem(0)
m.to=SendTo
m.Subject=Subject
m.Body=Body
If (Attachment <> "") Then
Mail.Attachments.Add(Attachment)
End If
m.Send
otl.Quit
Set m = Nothing
Set otl = Nothing
End Function
www.ramupalanki.com
For more QTP Realtime Scripts, visit www.ramupalanki.com

Call SendMail("a@thdf.com","hi","This is test mail for testing","")
'''''''''''''''create a new text file
=================================================
Dim fs,f
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.CreateTextFile("e:file1.txt")
f.WriteLine "hello"
f.WriteLine "this is sample data"
f.Close
Set fs=nothing
=================================================
'''''''''''''''read data from a text file
=================================================
Dim fs,f
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile("e:file1.txt",1)
While f.AtEndOfLine<>True
msgbox f.ReadLine
Wend
f.Close
Set fs=nothing
=================================================
''''''''''create a new excel file and write data
=================================================
Dim xl,wb,ws
Set xl=CreateObject("Excel.Application")
Set wb=xl.Workbooks.Add
Set ws=wb.Worksheets("sheet1")
ws.cells(1,1)=10
ws.cells(2,1)=20
ws.cells(3,1)=50
wb.SaveAs "e:file1.xls"
wb.Close
Set xl=nothing
=================================================
'''''''open existing file and write data in second column in Sheet1
=================================================
Dim xl,wb,ws
Set xl=CreateObject("Excel.Application")
Set wb=xl.Workbooks.Open("e:file1.xls")
Set ws=wb.Worksheets("sheet1")
ws.cells(1,2)="mindq"
ws.cells(2,2)="hyd"
ws.cells(3,2)="ap"
www.ramupalanki.com
For more QTP Realtime Scripts, visit www.ramupalanki.com

wb.Save
wb.Close
Set xl=nothing
=================================================
'''''''''''read data from excel from rows and columns
=================================================
Dim xl,wb,ws
Set xl=CreateObject("Excel.Application")
Set wb=xl.Workbooks.Open("e:file1.xls")
Set ws=wb.Worksheets("sheet1")
r=ws.usedrange.rows.count
c=ws.usedrange.columns.count
For i=1 to r
v=""
For j=1 to c
v=v&" "& ws.cells(i,j)
Next
print v
print "-----------------------"
Next
wb.Close
Set xl=nothing
=================================================
''''''''''''''''get the bgcolor in a cell in excel
=================================================
Dim xl,wb,ws
Set xl=CreateObject("Excel.Application")
Set wb=xl.Workbooks.Open("e:file3.xls")
Set ws=wb.Worksheets("sheet1")
r=ws.usedrange.rows.count
c=ws.usedrange.columns.count
For i=1 to r
For j=1 to c
x=ws.cells(i,j).interior.colorindex
msgbox x
Next
Next
wb.Close
Set xl=nothing
=================================================
'''''''''''''''''''''create word and write data
=================================================
dim mw
set mw=CreateObject("Word.Application")
www.ramupalanki.com
For more QTP Realtime Scripts, visit www.ramupalanki.com

mw.Documents.Add
mw.selection.typetext "hello"
mw.ActiveDocument.SaveAs "e:file1.doc"
mw.quit
set mw=nothing
=================================================
''''''''''script will display all the doc files in all the drives in the system
=================================================
Dim mw
Set mw=CreateObject("Word.Application")
Set fs=createobject("Scripting.FileSystemObject")
Set d=fs.Drives
mw.FileSearch.FileName="*.doc"
For each dr in d
msgbox dr
mw.FileSearch.LookIn=dr
mw.FileSearch.SearchSubFolders=True
mw.FileSearch.Execute
For each i in mw.FileSearch.FoundFiles
print i
Set f=fs.GetFile(i)
print f.Name&" "&f.Size&" "&f.DateCreated
print "-------------------------------------------------------------------"
Next
Next
mw.Quit
=================================================
'''''''''Open Internet Explorer and navigate to yahoomail
=================================================
Dim ie
Set ie=CreateObject("InternetExplorer.Application")
ie.Visible=True
ie.Navigate "www.yahoomail.com"
x=Browser("CreationTime:=0").GetROProperty("title")
msgbox x
=================================================
''''''Create word, Create table and write all the services names
=================================================
Set mw = CreateObject("Word.Application")
mw.Visible = True
Set dc = mw.Documents.Add()
Set objRange = dc.Range()
dc.Tables.Add
objRange,1,3
www.ramupalanki.com
For more QTP Realtime Scripts, visit www.ramupalanki.com

Set objTable = dc.Tables(1)
x=1
strComputer = "."
Set wms=GetObject("winmgmts:" & strComputer & "rootcimv2")
Set colItems = wms.ExecQuery("Select * from Win32_Service")
For Each s 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 = s.Name
objTable.Cell(x, 2).Range.text = s.DisplayName
objTable.Cell(x, 3).Range.text = s.State
x=x+1
Next




www.ramupalanki.com

More Related Content

More from Ramu Palanki

Qtp material for beginners
Qtp material for beginnersQtp material for beginners
Qtp material for beginners
Ramu Palanki
 
Qtp interview questions
Qtp interview questionsQtp interview questions
Qtp interview questions
Ramu Palanki
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
Ramu Palanki
 
Qtp interview questions3
Qtp interview questions3Qtp interview questions3
Qtp interview questions3
Ramu Palanki
 
Qtp compare two xml files
Qtp compare two xml filesQtp compare two xml files
Qtp compare two xml files
Ramu Palanki
 
Qtp change excel cell color with condition
Qtp change excel cell color with conditionQtp change excel cell color with condition
Qtp change excel cell color with condition
Ramu Palanki
 
Qtp certification questions and tutorial
Qtp certification questions and tutorialQtp certification questions and tutorial
Qtp certification questions and tutorial
Ramu Palanki
 
Qtp automation estimation techniques
Qtp automation estimation techniquesQtp automation estimation techniques
Qtp automation estimation techniques
Ramu Palanki
 
Qtp 11 new enhacements in
Qtp 11 new enhacements inQtp 11 new enhacements in
Qtp 11 new enhacements in
Ramu Palanki
 
Qtp passing parameters between actions
Qtp passing parameters between actionsQtp passing parameters between actions
Qtp passing parameters between actions
Ramu Palanki
 
Qtp wsh scripts examples
Qtp wsh scripts examplesQtp wsh scripts examples
Qtp wsh scripts examples
Ramu Palanki
 
Quick test professional certifcation questions and tutorial2
Quick test professional certifcation questions and tutorial2Quick test professional certifcation questions and tutorial2
Quick test professional certifcation questions and tutorial2
Ramu Palanki
 
Quality center certification questions
Quality center certification questionsQuality center certification questions
Quality center certification questions
Ramu Palanki
 
Qtp+real time+test+script
Qtp+real time+test+scriptQtp+real time+test+script
Qtp+real time+test+script
Ramu Palanki
 
What are the features in qtp
What are the features in qtpWhat are the features in qtp
What are the features in qtp
Ramu Palanki
 
Testing interview questions
Testing interview questionsTesting interview questions
Testing interview questions
Ramu Palanki
 

More from Ramu Palanki (20)

Qtp presentation
Qtp presentationQtp presentation
Qtp presentation
 
Qtp material for beginners
Qtp material for beginnersQtp material for beginners
Qtp material for beginners
 
Qtp interview questions
Qtp interview questionsQtp interview questions
Qtp interview questions
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
 
Qtp interview questions3
Qtp interview questions3Qtp interview questions3
Qtp interview questions3
 
Qtp compare two xml files
Qtp compare two xml filesQtp compare two xml files
Qtp compare two xml files
 
Qtp change excel cell color with condition
Qtp change excel cell color with conditionQtp change excel cell color with condition
Qtp change excel cell color with condition
 
Qtp certification questions and tutorial
Qtp certification questions and tutorialQtp certification questions and tutorial
Qtp certification questions and tutorial
 
Qtp best tutorial
Qtp best tutorialQtp best tutorial
Qtp best tutorial
 
Qtp basic stuff
Qtp basic stuffQtp basic stuff
Qtp basic stuff
 
Qtp automation estimation techniques
Qtp automation estimation techniquesQtp automation estimation techniques
Qtp automation estimation techniques
 
Qtp 11 new enhacements in
Qtp 11 new enhacements inQtp 11 new enhacements in
Qtp 11 new enhacements in
 
Qtp sample resume
Qtp sample resumeQtp sample resume
Qtp sample resume
 
Qtp passing parameters between actions
Qtp passing parameters between actionsQtp passing parameters between actions
Qtp passing parameters between actions
 
Qtp wsh scripts examples
Qtp wsh scripts examplesQtp wsh scripts examples
Qtp wsh scripts examples
 
Quick test professional certifcation questions and tutorial2
Quick test professional certifcation questions and tutorial2Quick test professional certifcation questions and tutorial2
Quick test professional certifcation questions and tutorial2
 
Quality center certification questions
Quality center certification questionsQuality center certification questions
Quality center certification questions
 
Qtp+real time+test+script
Qtp+real time+test+scriptQtp+real time+test+script
Qtp+real time+test+script
 
What are the features in qtp
What are the features in qtpWhat are the features in qtp
What are the features in qtp
 
Testing interview questions
Testing interview questionsTesting interview questions
Testing interview questions
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Qtp excel scripts

  • 1. For more QTP Realtime Scripts, visit www.ramupalanki.com MS Excel Scripts '''Script to create a new excel file , write data '''save the file with read and write protected '''''pwd1 is for read protected pwd2 is for write protected Set xl=CreateObject("Excel.Application") Set wb=xl.Workbooks.Add xl.DisplayAlerts=False Set ws=wb.Worksheets("sheet1") ws.cells(1,1)=100 ws.cells(1,2)=200 wb.Saveas "e:data2.xls",,"pwd1","pwd2" wb.Close Set xl=nothing '''Script to open excel file ,which is read and write protected write data '''''pwd1 is for read protected pwd2 is for write protected Set xl=CreateObject("Excel.Application") Set wb=xl.Workbooks.Open("e:data2.xls",0,False,5,"pwd1","pwd2") xl.DisplayAlerts=False Set ws=wb.Worksheets("sheet1") ws.cells(1,2)="hello" ws.cells(2,2)="new data" wb.Save wb.Close Set xl=nothing ''Script to get the list of links in Google and do spell check ================================================= dim d set mw=CreateObject("Word.Application") set d=Description.Create d("micclass").value="Link" set a=Browser("Google").page("Google").childobjects(d) for i=0 to a.count-1 mw.WordBasic.filenew s=a(i).getROProperty("innertext") mw.WordBasic.insert s if mw.ActiveDocument.Spellingerrors.count>0 then www.ramupalanki.com
  • 2. For more QTP Realtime Scripts, visit www.ramupalanki.com Reporter.ReportEvent 1,"Spelling","spelling error :"&s end if mw.ActiveDocument.Close(False) next mw.quit set mw=nothing ========================================= ''''Script to check ON the checkboxes in yahoo mail inbox ========================================= Dim d Set d=Description.Create d("micclass").value="WebCheckBox" Set c=Browser("Inbox (17) - Yahoo! Mail").Page("Inbox (17) - Yahoo! Mail").ChildObjects(d) For i=1 to 10 c(i).set "ON" Next ======================================== '''script to select a mail having subject 'hi' or 'HI' ======================================== n=Browser("yahoo").Page("yahoo").WebTable("Inbox").RowCount For i=2 to n s=Browser("yahoo").Page("yahoo").WebTable("Inbox").GetCellData(i,7) If lcase(trim(s))="hi" Then Browser("yahoo").Page("yahoo").WebCheckBox("index:="&i-1).set "ON" End If Next ======================================== '''''Function to send a mail ======================================== Function SendMail(SendTo, Subject, Body, Attachment) Set otl=CreateObject("Outlook.Application") Set m=otl.CreateItem(0) m.to=SendTo m.Subject=Subject m.Body=Body If (Attachment <> "") Then Mail.Attachments.Add(Attachment) End If m.Send otl.Quit Set m = Nothing Set otl = Nothing End Function www.ramupalanki.com
  • 3. For more QTP Realtime Scripts, visit www.ramupalanki.com Call SendMail("a@thdf.com","hi","This is test mail for testing","") '''''''''''''''create a new text file ================================================= Dim fs,f Set fs=CreateObject("Scripting.FileSystemObject") Set f=fs.CreateTextFile("e:file1.txt") f.WriteLine "hello" f.WriteLine "this is sample data" f.Close Set fs=nothing ================================================= '''''''''''''''read data from a text file ================================================= Dim fs,f Set fs=CreateObject("Scripting.FileSystemObject") Set f=fs.OpenTextFile("e:file1.txt",1) While f.AtEndOfLine<>True msgbox f.ReadLine Wend f.Close Set fs=nothing ================================================= ''''''''''create a new excel file and write data ================================================= Dim xl,wb,ws Set xl=CreateObject("Excel.Application") Set wb=xl.Workbooks.Add Set ws=wb.Worksheets("sheet1") ws.cells(1,1)=10 ws.cells(2,1)=20 ws.cells(3,1)=50 wb.SaveAs "e:file1.xls" wb.Close Set xl=nothing ================================================= '''''''open existing file and write data in second column in Sheet1 ================================================= Dim xl,wb,ws Set xl=CreateObject("Excel.Application") Set wb=xl.Workbooks.Open("e:file1.xls") Set ws=wb.Worksheets("sheet1") ws.cells(1,2)="mindq" ws.cells(2,2)="hyd" ws.cells(3,2)="ap" www.ramupalanki.com
  • 4. For more QTP Realtime Scripts, visit www.ramupalanki.com wb.Save wb.Close Set xl=nothing ================================================= '''''''''''read data from excel from rows and columns ================================================= Dim xl,wb,ws Set xl=CreateObject("Excel.Application") Set wb=xl.Workbooks.Open("e:file1.xls") Set ws=wb.Worksheets("sheet1") r=ws.usedrange.rows.count c=ws.usedrange.columns.count For i=1 to r v="" For j=1 to c v=v&" "& ws.cells(i,j) Next print v print "-----------------------" Next wb.Close Set xl=nothing ================================================= ''''''''''''''''get the bgcolor in a cell in excel ================================================= Dim xl,wb,ws Set xl=CreateObject("Excel.Application") Set wb=xl.Workbooks.Open("e:file3.xls") Set ws=wb.Worksheets("sheet1") r=ws.usedrange.rows.count c=ws.usedrange.columns.count For i=1 to r For j=1 to c x=ws.cells(i,j).interior.colorindex msgbox x Next Next wb.Close Set xl=nothing ================================================= '''''''''''''''''''''create word and write data ================================================= dim mw set mw=CreateObject("Word.Application") www.ramupalanki.com
  • 5. For more QTP Realtime Scripts, visit www.ramupalanki.com mw.Documents.Add mw.selection.typetext "hello" mw.ActiveDocument.SaveAs "e:file1.doc" mw.quit set mw=nothing ================================================= ''''''''''script will display all the doc files in all the drives in the system ================================================= Dim mw Set mw=CreateObject("Word.Application") Set fs=createobject("Scripting.FileSystemObject") Set d=fs.Drives mw.FileSearch.FileName="*.doc" For each dr in d msgbox dr mw.FileSearch.LookIn=dr mw.FileSearch.SearchSubFolders=True mw.FileSearch.Execute For each i in mw.FileSearch.FoundFiles print i Set f=fs.GetFile(i) print f.Name&" "&f.Size&" "&f.DateCreated print "-------------------------------------------------------------------" Next Next mw.Quit ================================================= '''''''''Open Internet Explorer and navigate to yahoomail ================================================= Dim ie Set ie=CreateObject("InternetExplorer.Application") ie.Visible=True ie.Navigate "www.yahoomail.com" x=Browser("CreationTime:=0").GetROProperty("title") msgbox x ================================================= ''''''Create word, Create table and write all the services names ================================================= Set mw = CreateObject("Word.Application") mw.Visible = True Set dc = mw.Documents.Add() Set objRange = dc.Range() dc.Tables.Add objRange,1,3 www.ramupalanki.com
  • 6. For more QTP Realtime Scripts, visit www.ramupalanki.com Set objTable = dc.Tables(1) x=1 strComputer = "." Set wms=GetObject("winmgmts:" & strComputer & "rootcimv2") Set colItems = wms.ExecQuery("Select * from Win32_Service") For Each s 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 = s.Name objTable.Cell(x, 2).Range.text = s.DisplayName objTable.Cell(x, 3).Range.text = s.State x=x+1 Next www.ramupalanki.com