Forum Discussion

Philip_Baird's avatar
Philip_Baird
Community Expert
11 years ago

Cannot share User Forms between Projects?


Hi, In a Test Suite, I have two Projects, ProjectA and ProjectB.


 


In ProjectA, I have a simple form, UserForm1, with a button and textbox and the following code in a Script Unit, UserForm1.sj, that starts the form and handles the button click:


 


function startForm() {


  UserForms.UserForm1.ShowModal();


}


 


function UserForm1_cxButton1_OnClick(Sender)


{


  var form = UserForms.UserForm1;


  


  form.cxTextEdit1.Text = "abc";


}


 


This works fine in ProjectA, however, if I add the form UserForm1, and the Script Unit UserForm1.sj to ProjectB via "Add | Existing Item..." from ProjectA, the button click fails with the following error:


 


"Unable to execute the "OnClick" event of the "cxButton1" object. The "UserForm1_cxButton1_OnClick" method cannot be found or it has an invalid number of parameters."


 


I have tried a number of combinations of forms, including sharing between Projects in different Test Suites, and always end up with the error.


 


Is this a limitation in Test Complete that User Forms cannot be shared between Projects?


 


Regards,


Phil Baird


  • Hi Phil,


     


    This is a limitation of user forms - associated events cannot be shared among projects. We have a suggestion in our database to make it possible - I've increased its rating. Thank you.


     


    Currently, you can make your forms with event handlers available to all projects if you add them to a script extension instead of sharing them.


    Refer to the "Script Extensions" and "Using Forms in Script Extensions" articles for more information.


     

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Phil,


     


    This is a limitation of user forms - associated events cannot be shared among projects. We have a suggestion in our database to make it possible - I've increased its rating. Thank you.


     


    Currently, you can make your forms with event handlers available to all projects if you add them to a script extension instead of sharing them.


    Refer to the "Script Extensions" and "Using Forms in Script Extensions" articles for more information.