Deep Patel: December 2012

Wednesday, December 26, 2012

Running a PASSPORT Emulator macro using a Visual Basic Application(Excel Macro)


Title
Running a PASSPORT Emulator macro using a Visual Basic Application(Excel Macro)

Product
PASSPORT PC TO HOST

Emulation Types
SCO ANSI, Wyse 60, TN3270, TN5250, VT

Issue
Need to run a PASSPORT Macro from a Visual Basic Application.

Please see the following sample macro below:

Sub runmacro_zam()
    navigateto "C:\progra~1\passport\login.zam"
End Sub

Sub runmacro_zmc()
    navigateto "C:\progra~1\passport\login.zmc"
End Sub

Sub navigateto(macroname)
    Dim objSys
    Dim objSess
   
    Set objSys = CreateObject("PASSPORT.System")
    Set objSess = objSys.ActiveSession
   
    ' Assume you already have a PASSPORT session running
    objSess.navigateto macroname
End Sub

' You can use this too, but it will not work with a .zmc macro
Sub runmacro()
    Dim WshShell
   
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Exec ("C:\progra~1\passport\passatmr.exe /A 0 0 c:\progra~1\passport\login.zam")
End Sub

Thursday, December 13, 2012

Excel 2003 Datasheet not getting imported in QTP 10 Datatable

Recently faced issue,
"Excel 2003 Datasheet not getting imported in QTP 10 Datatable"

Environment Conditions:
- QTP 10
- Excel 2003/2007/2010 with no Excel Addins installed(Addins like Data Classification tools)
- Win XP/7
- File Format of Data Sheet (.xls or 97-2003)


Drilling Down...
Tried many things...
checking compatibility mode of Excel workbook, column headers, etc. Nothing worked.

Finally I tried data row by data row.
Created a new excel with same headers, just went on adding set of rows and finally drilled down to row which had the problem.

Root Cause:

The data in the column contained n-Dash instead of Hyphen
n-Dash being UNICODE character occupies more space and then hyphen(an ASCII).

Now when the total character size of cells containing Unicode characters increases beyond a certain limit(not sure about the limit but this is what I got from the set of execution I performed), QTP is not able to import any sheet of that Excel Workbook.

The difference can be seen below. n-dash in 1st row and hyphen in 2nd.






Solution: Replace all n-Dash by Hyphen

Try this if you too are facing a similar problem. Hope it helps...

Cheers....