Compare 2 Excel sheets cell by cell
This code will open two excel sheet and compare each sheet cell by cell, if any changes there in cells , it will highlight the cells in red color in the first sheet.
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = True
Set objWorkbook1= objExcel.Workbooks.Open(“C:Documents andSettingsmohan.kakarlaDesktopDocs1.xls”)
Set objWorkbook2= objExcel.Workbooks.Open(“C:Documents and
Settingsmohan.kakarlaDesktopDocs2.xls”)
Set objWorksheet1= objWorkbook1.Worksheets(1)
Set objWorksheet2= objWorkbook2.Worksheets(1)
For Each cell In objWorksheet1.UsedRange
If cell.Value <> objWorksheet2.Range(cell.Address).Value Then
cell.Interior.ColorIndex = 3’Highlights in red color if any changes in cells
Else
cell.Interior.ColorIndex = 0
End If
Next
set objExcel=nothing
Author: Mohan Kumar Kakarla
Excel Sorting(Ascending , Descending) By Rows and Columns
Excel Sorting By Row:
Const xlAscending = 1
Const xlNo = 2
Const xlSortRows = 2
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open(“C:Documents and Settingsmohan.kakarlaDesktopDocs1.xls”)
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Cells(1,1).activate
Set objRange = objExcel.ActiveCell.EntireRow
objRange.Sort objRange, xlAscending, , , , , , xlNo, , , xlSortRows
set objExcel=nothing
Excel Sorting By Colum :
Const xlAscending = 1’represents the sorting type 1 for Ascending 2 for Desc
Const xlYes = 1
Set objExcel = CreateObject(“Excel.Application”)’Create the excel object
objExcel.Visible = True’Make excel visible
Set objWorkbook = _
objExcel.Workbooks.Open(“C:\Documents and Settings\mohan.kakarla\Desktop\Docs1.xls”)’Open the
document
Set objWorksheet = objWorkbook.Worksheets(1)’select the sheet based on the index .. 1,2 ,3 …
Set objRange = objWorksheet.UsedRange’which select the range of the cells has some data other than blank
Set objRange2 = objExcel.Range(“A1”)’ select the column to sort
objRange.Sort objRange2, xlAscending, , , , , , xlYes
set objExcel=nothing
Reference: MSDN
Whats New In QTP 9.5
Maintenance Run Mode :
Repair your test on the fly, this will assists you to adding the steps or uodating the object proprties in OR on the fly.i.e. if your object properties are changed after a new build, you just run the Maintenance Run Mode and update your OR according to that on the fly.
Process Guidance :
This is little more than more accessible help files. Maybe this is good for when you are first learning to record a test, but it doesn’t seem to add much utility.
Available Keywords Pane
All Test Objects and functions in one handy location.Rapid test development with drag & drop.Object repository now also supports drag & drop
Resources Pane :
All resources associated with the test. You can see all your library file in this pane
1.Anyone can add support for new web controls
2.Rapid development in JavaScript
3.Solid infrastructure supplied by the Web add-in
4.Extensibility objects are first class citizens
5.Built-in toolkit: ASPAjax
Tabs identified as separate browsers.Same test compatible with tabbed and non tabbed browsers.
1.PowerBuilder
2. Oracle − Forms 10 −Apps 12
3.StingRay Objective Grid 10, 114. PeopleSoft 9.0•
4.New Terminal Emulator versions
5.NET 3.5 (beta)
1.Windows Vista 64 bit
2. Eclipse 3.2, 3.3
3.Record on SWT
4. Firefox 3.0
5.Netscape 9
Reference: HP website
You can download QTP 9.5 on HP website https://h10078.www1.hp.com/cda/hpms/display/main/hpms_content.jsp?zn=bto&cp=1-11-127-24^1352_4000_100__
Uninstall a software using vbscript , QTP
This works for uninstalling most applications. In this example I will show how AutoCAD 2005 can be uninstalled using a VBScript. Open Regedit and look in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall search for the application and find a the product code that is in GUID format looking like this: {5783F2D7-0301-0409-0002-0060B0CE6BBA} It might be something else for you. The code below will uninstall AutoCAD 2005 as well as Express Tools. Copy the code below into Notepad and give the file the extension vbs.on error resume next
Set WshShell = CreateObject("WScript.Shell")
' Uninstall Express Tools
WshShell.Run "msiexec /x {5783F2D7-0311-0409-0000-0060B0CE6BBA} /q",1,true
' Uninstall AutoCAD 2005
WshShell.Run "msiexec /x {5783F2D7-0301-0409-0002-0060B0CE6BBA} /q",1,true
Reference:JTBWorld blog
Uninstall a software using vbscript , QTP
This works for uninstalling most applications. In this example I will show how AutoCAD 2005 can be uninstalled using a VBScript. Open Regedit and look in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall search for the application and find a the product code that is in GUID format looking like this: {5783F2D7-0301-0409-0002-0060B0CE6BBA} It might be something else for you. The code below will uninstall AutoCAD 2005 as well as Express Tools. Copy the code below into Notepad and give the file the extension vbs.on error resume next
Set WshShell = CreateObject("WScript.Shell")
' Uninstall Express Tools
WshShell.Run "msiexec /x {5783F2D7-0311-0409-0000-0060B0CE6BBA} /q",1,true
' Uninstall AutoCAD 2005
WshShell.Run "msiexec /x {5783F2D7-0301-0409-0002-0060B0CE6BBA} /q",1,true
Reference:JTBWorld blog
Can we create the window application with VBScipt?
Can we create the window application with VBScipt?
yes: using HTML Application (HTA)
An HTML Application (HTA) is a Microsoft Windows application written with HTML and Dynamic HTML. The ability to write HTAs was introduced with Microsoft Internet Explorer 5.0.
HTAs can be made from regular HTML files by simply changing the file extension to .hta. A regular HTML file is confined to the security model of the web browser – i.e. to communicating with the server, manipulating the page’s object model (usually to validate forms and / or create interesting visual effects) and reading / writing cookies. An HTA runs as a fully trusted application and therefore has more privileges than a normal HTML file – for example an HTA can create / edit / remove files and registry entries.
To customize the appearance of an HTA, a new tag, with attributes, is introduced: <hta:application …>. This tag appears in the <head>…</head> section of an HTA document.
Because an HTA has more privileges than an HTML page, it cannot be executed via http. Rather, the HTA must be downloaded (just like an EXE file) and executed from local file system.
QTP code Generates for a HTML Application
QTP generates the code as similar to the normal web applications, except that it shows window instead of browser
Example: If the HTML Application has a edit box then code will be
Window(..).Webedit(…).set “value”
Sample code :
This example code creates a HTML app with 3 edit boxes.
<SCRIPT Language=”VBScript”>
Sub SetNameColor
If Len(UserName.Value) <> 0 Then
UserName.style.background = “cyan”
Else
UserName.style.background = “yellow”
End If
End Sub
</SCRIPT>
<body>
Name<br>
<input type=”text” name=”UserName” size=”25″ style=”background-color:yellow” onChange=”SetNameColor”><p>
Address<br>
<input type=”text” name=”Address” size=”25″><p>
Phone<br>
<input type=”text” name=”Phone” size=”25″><p>
</body>
For More information on HTML Application Refer:
http://msdn2.microsoft.com/en-us/library/ms536496.aspx
http://www.microsoft.com/technet/scriptcenter/resources/qanda/htas.mspx
References:MSDN
Get all files within a time range or specified time
Dim From
From = TimeSerial( 11, 0, 0 ) ‘ to emphasize 24 hour clock! 11 AM
Dim Till
Till = TimeSerial( 13, 0, 0 )
Dim oFS
Set oFS = CreateObject( “Scripting.FileSystemObject” )
Dim oFile, tFile, Range
For Each oFile In oFS.getFolder( “.\” ).Files
tmFile = TimeValue( oFile.DateCreated )
bInRange = tFile >= From And tFile <= Till
msgbox oFile.DateCreated &”–“& oFile.Name
Next
Dictonary Object
Dictionary Object
Dictionary Object stores data key, item pairs. A Dictionary object stores the items in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually an integer or a string, but can be anything except an array.
Adavntages of using it in QTP:
1. can be used as Global variable declaration. so that any test can access the values from it in the run time.
2. You can store and retrive any number of run time values in to dictonary.
3. It is one of the Parameterization techique we can use in QTP
Disadvantages:
we can not specify the values in the desingn time like Datatable , Action parameters, environment variable.
So it is useful only in Run time , not design time
Methods:
Add Method
Adds a key and item pair to a Dictionary
object. object.Add (key, item)
Arguments
object Required. Always the name of a Dictionary object.
key Required. The key associated with the item being added.item Required.
The item associated with the key being added.
Remarks
An error occurs if the key already exists.
The following example illustrates the use of the Add method.
Dim d ‘ Create a variable.
Set d = CreateObject(“Scripting.Dictionary”)
d.Add “a”, “Athens” ‘ Add some keys and items.
d.Add “b”, “Belgrade”
Items Method
Returns an array containing all the items in a Dictionary object.
Remarks The object is always the name of a Dictionary object.The following code illustrates use of the Items method:
Exists Method
Returns true if a specified key exists in the Dictionary object, false if it does not.
object.Exists(key)
Arguments
object Required. Always the name of a Dictionary object.
key Required. Key value being searched for in the Dictionary object.
Remarks
The following example illustrates the use of the Exists method.
Keys Method
Returns an array containing all existing keys in a Dictionary object.
object.Keys( )
Remarks
The object is always the name of a Dictionary object.
The following code illustrates use of the Keys method:
Remove Method
Removes a key, item pair from a Dictionary object.
object.Remove(key)
Arguments
object Required. Always the name of a Dictionary object.
key Required. Key associated with the key, item pair you want to remove from the Dictionary object.
Remarks
An error occurs if the specified key, item pair does not exist.
The following code illustrates use of the Remove method:
RemoveAll Method
The RemoveAll method removes all key, item pairs from a Dictionary object.
object.RemoveAll( )
Author: Mohan Kakarla
Reference:MSDN
Get The Latest Created File
Const cdtFirst = #1/1/100#
Dim sFolder : sFolder = “.\”
Dim oFS : Set oFS = CreateObject( “Scripting.FileSystemObject” )
Dim dtLatest : dtLatest = cdtFirst
Dim sExt : sExt = “ppt” ‘ not entirely sure about this extension
Dim oLFile : Set oLFile = Nothing
Dim oFile
For Each oFile in oFS.GetFolder( sFolder ).Files
If sExt = LCase( oFS.GetExtensionName( oFile.Name ) ) Then
If dtLatest < oFile.DateLastAccessed Then ‘ maybe DateCreated/DateLastModified
dtLatest = oFile.DateLastAccessed
Set oLFile = oFile
End If
End If
Next
If oLFile Is Nothing Then
WScript.Echo “No file with extension”, sExt, “found.”
Else
WScript.Echo “found”, oLFile.Name, oLFile.DateLastAccessed
End If
-
Archives
- July 2011 (1)
- March 2011 (1)
- November 2010 (1)
- November 2008 (4)
- October 2008 (2)
- September 2008 (2)
- June 2008 (1)
- March 2008 (4)
- February 2008 (44)
-
Categories
- Automated Test Script Creation Process
- Automating MS Word
- Automating QC
- Automation Object Model For QTP
- Backward compatability in QTP
- Browser Scripts
- COM and QTP
- compare 2 text files
- Descriptive programming
- Descriptive Programming and Child Objetcs
- Dictonary Object
- DotNetFactory
- Excel Automation
- Extra Topics
- Files and Folders
- General Standards to be followed in Test scripts
- New Features In QTP9.5
- QC-OTA
- QTP Additional Faqs
- QTP Faqs
- QTP Naming Convention
- QTP Tips and Faqs
- Running stored procedures from QTP
- Send keyboard keys
- Uncategorized
- Uninstall a software using QTP
- Uninstall a software using vbscript
- Update data in a database
- VBScript and IE Automation
- VBScript Faqs and Useful resources
- What’s New in Quick Test Pro 9.0
- Whats New in QTP 9.5
- XML Scripting
-
RSS
Entries RSS
Comments RSS