preload

GP/QTP Automation: Highlight controls in Dexterity Window

Posted by Albert Gareev on Oct 26, 2009 | Categories: Great PlainsSource code


SanScript, Visual Basic, and VBScript functions implementing the “Highlight in Application” feature as in QTP Object Repository Manager.

All related posts: Reference Page – GP/QTP Automation  

VBA/SanScript function – put in your Excel VBA macro file

Note. Ignores sanScript errors


Public Function HighlightControl()
    Dim intRC As Integer
    Dim intCount, Iter As Integer
    Dim sCode, sErrMsg As String
    Dim sControlName As String

    sControlName = Workbooks.Item(1).Sheets.Item(1).Cells(2, 1)
   
    Call GPApp.Activate
   
    'Show/Hide
    intCount = 3
    For Iter = 1 To intCount
        sCode = "hide field " & sControlName & ";"
        intRC = GPApp.ExecuteSanScript(sCode, sErrMsg)
        Sleep 300
        sCode = "show field " & sControlName & ";"
        intRC = GPApp.ExecuteSanScript(sCode, sErrMsg)
        Sleep 300
    Next   

End Function

VBScript function – put as Dexterity Interface Class method

Note. If you use it as an embedded function don’t forget to call COM initialization procedures first.


 Public Function HighlightControl(ByVal sName)
  Dim boolRC, intRC
  Dim objUsedRange'
     Set objUsedRange = XLBook.Worksheets(1).UsedRange()
        objUsedRange.Cells(2,1) = " " & sName 'space char is apostrophe workaround

  XLHandle.Run("HighlightControl")

 End Function

A function to highlight all window controls one by one

Note.

Uses XML structure created by GUI Capture script

Uses Service Functions – XML (QTP, VBScript)


Public Function GP_HighlightContext(ByRef objXMLContext)
   Dim objColl, objColl2, objControl, objXMLDesc
   Dim objProperty, sName, sDexParent, sDexName, sFullName
   Dim Iter, Jter

   If (objXMLContext is Nothing) Then Exit Function End If

   sDexParent = ChildAttributeValueByName(objXMLContext, "dexhost")
   Set objColl = objXMLContext.ChildElementsByPath("./Object")

   For Iter = 1 To objColl.Count
    Set objControl = objColl.Item(Iter)

       Set objXMLDesc = ChildElementByName(objControl, "desc")
    Set objColl2 = objXMLDesc.ChildElementsByPath("./property")
    For Jter = 1 To objColl2.Count
     Set objProperty = objColl2.Item(Jter)
     sName = ChildAttributeValueByName(objProperty, "name")
     If LCase(sName) = "dexname" Then
      sDexName = ChildAttributeValueByName(objProperty, "value")
      sFullName = "'" & sDexName & "' of "  & sDexParent
      GPHandle.HighlightControl(sFullName)
      Exit For
     End If
    Next

   Next

End Function


Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.