Ask a Question

Identify current form for script use

Occasional Contributor

Identify current form for script use


   I am trying to write a reusable script with a data loop in TestComplete 12, VB Script.

Is there a way for me to identify the current active form? I have searched extensively and found nothing.


My script interacts with a data grid and enters a file determined number of items and is quite simple but I would like to use this identification feature in other scripts as well. The grid is on the same location of every form but the form name changes example below: 

1.  Sys.Process("Signon").WinFormsObject("frmPSSales").WinFormsObject("RightFillPan").WinFormsObject("clientPanel").WinFormsObject("SpDataGrid1")

2. Sys.Process("Signon").WinFormsObject("frmPSOrders").WinFormsObject("RightFillPan").WinFormsObject("clientPanel").WinFormsObject("SpDataGrid1")


I would like to capture the current "Sys.Process("Signon").WinFormsObject("********")." of the current form so it does not have to passed in to the function.


An example of what im doing is below:


frm = ""
frm = "This would be the retrieved form fullname or mapped name"
Call Project.Variables.itemNum.Reset
While Not Project.Variables.itemNum.IsEOF
'Enters the text Project.Variables.itemNum("ItemNumber") in the 'txtBase' text editor.
Call frm.UcGetItemA1.panBase.txtBase.SetText(Project.Variables.itemNum.Value("ItemNumber"))
'Enters '[Enter]' in the 'txtBase' object.
Call frm.UcGetItemA1.panBase.txtBase.Keys("[Enter]")
'Enters '[Enter]' in the 'SPTextBox' object.
Call frm.SPTextBox.Keys("[Enter]")
Call Project.Variables.itemNum.Next
End Sub


Any help is greatly appreciated.

Community Hero

This may be of some help

[Community Hero]
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.

Use find for the object which keeps changing
For example for your script try with the below line it should work or else just find correct the name property name correctly with Asterik on the changing field : 

SmartBear Alumni (Retired)

Thank you for helping everyone!


@ZXQA does this help? Please let us know how you solved the issue.

Sonya Mihaljova
Community and Education Specialist

SmartBear Alumni (Retired)

@ZXQA Could you take a look at this help topic and let me know if this helps?


Sonya Mihaljova
Community and Education Specialist

Occasional Contributor

Thank you Sonya! I will review it and see if it is what i am after as soon as I am back at work. Thank you again.

Showing results for 
Search instead for 
Did you mean: