Hi. Happy Friday once again! I have an amazing function for you today! This function saves you loads of time and coding! It imports all of your excel data sheets quickly into your script by simply adding the path of your excel sheet. Let's get started!
1. Copy and paste the two functions below into your QTP/UFT script
Set excelApp = CreateObject("Excel.Application")
intSheetCount = excelApp.Worksheets.Count
'Loop through the excel sheet and get all of the sheet names
For i = 1 To intSheetCount
ReDim Preserve arrSheetName(i)
arrSheetName(i) = excelApp.Worksheets(i).Name
'now we must clear the excel object and release it so that we can import with QTP
Set excelApp = Nothing
For i = 1 To UBound(arrSheetName)
Public Sub fn_kill_Executable(Exe_Name)
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '"&Exe_Name&"'")
For Each objProcess In colProcessList
On Error Resume Next
On Error GoTo 0
Set colProcessList = Nothing
Set objWMIService = Nothing
2. Now call the function and enter the path where your excel sheet is located. Make sure to include the excel workbook name and extenstion at the end of the path. See example below:
3. Now that your script ran, within the results report, click on the data tab in the lower right hand corner, and you should see your imported data! Amazing right!
Stay tuned for more amazing tips and tricks!! Please leave your feedback and comments below!
Latest posts by Admin (see all)
- SQA QTP tutorial – WebList identified as a web element and how to select an item from this list - December 9, 2015
- Automation QTP tutorial-double clicking on any object - December 4, 2015
- Software Automation QTP tutorial – 5 top reasons for using automation - November 23, 2015