Join Wintertainment 2021 to share your stories, have fun, earn community badges, and more!

ProjectIntegration Object

Applies to TestComplete 15.10, last modified on December 01, 2021


The ProjectIntegration object represents the project opened in TestComplete. It provides methods and properties that let you manage the collection of scripts included in the project. To obtain the ProjectIntegration object, connect to TestComplete via COM and use the Project property of the TestComplete Integration object. For more information, see Working With TestComplete via COM.



The following example demonstrates how you can work with script units of the project currently opened in TestComplete.

Visual Basic

Sub Test()

  Dim TestCompleteApp As TestCompleteApplication
  Dim IntegrationObject As ItcIntegration
  Dim LastResult As ItcIntegrationResultDescription

  ' Creates the application object
  Set TestCompleteApp = CreateObject("TestComplete.TestCompleteApplication.15")

  ' Obtains the integration object
  Set IntegrationObject = TestCompleteApp.Integration

  ' Opens the project
  ProjectPath = "C:\Work Folder\TestSuite\TestSuite.pjs"
    IntegrationObject.OpenProjectSuiteEx (ProjectPath)

  ' Needed to process errors
  On Error GoTo Err_Label

    ' Obtains the ProjectIntegration object
    Set ProjectIntegration = IntegrationObject.Project("TestProject_VB")
    ' Specifies the script unit file
    UnitPath = "C:\Work Folder\TestSuite\TestProject_VB\Script\Test4_VB.svb"
    ' Checks whether the project contains the specified script unit
    If ProjectIntegration.HasUnit(UnitPath) Then
      ' If the project contains the unit
      ' Displays an informative message
      MsgBox "The project already contains the specified script unit"
      ' If the project does not contain the unit
      ' Adds the unit to the project
      ProjectIntegration.AddUnit (UnitPath)


      ' Removes the added unit from the project
      ProjectIntegration.RemoveUnit (UnitPath)
    End If

    ' Process errors
    If Err.Number <> 0 Then
      MsgBox Err.Description, vbCritical, "Error"
    End If

  ' Closes TestComplete

End Sub


// Add the following lines to your code
using System.Runtime.InteropServices;
using TestComplete;

public partial class Form1 : Form
  public Form1()

  private void btn_Connect_Click(object sender, EventArgs e)
    const string TCProgID = "TestComplete.TestCompleteApplication.15";
    string ProjectSuitePath = "C:\\Work Folder\\TestSuite\\TestSuite.pjs";
    string ProjectPath = "C:\\Work Folder\\TestSuite\\TestProject_CS";
    string ProjectName = "TestProject_CS";
    object TestCompleteObject = null;
    string FilePath;

    // Obtains access to TestComplete
      TestCompleteObject = Marshal.GetActiveObject(TCProgID);
        TestCompleteObject = Activator.CreateInstance(Type.GetTypeFromProgID(TCProgID));

    if (TestCompleteObject == null) return;

    // Obtains ITestCompleteCOMManager
    TestComplete.ITestCompleteCOMManager TestCompleteManager = (TestComplete.ITestCompleteCOMManager)TestCompleteObject;
    // Obtains Integration object
    TestComplete.ItcIntegration IntegrationObject = TestCompleteManager.Integration;
    // Loads the project suite
      // Obtains ProjectIntegration object
      TestComplete.ItcProjectIntegration Project = IntegrationObject.get_Project(ProjectName);

      // Shows the Open File dialog allowing to select a script unit to add to the project
      OpenFileDialog.InitialDirectory = ProjectPath + "\\Script";
      OpenFileDialog.Filter = "C#Script files|*.scs";
      if (OpenFileDialog.ShowDialog() == DialogResult.OK)
        FilePath = OpenFileDialog.FileName;
        if (Project.get_HasUnit(FilePath))
          // If the project already contains the selected unit
          // Displays the informative message
          MessageBox.Show("The project already contains this script unit");
          // If the project does not contain the selected unit
          // Adds the unit to the project


          // Removes the added unit from the project
    catch (System.Runtime.InteropServices.COMException ex)
      System.Windows.Forms.MessageBox.Show("An exception occurred: " + ex.Message);
      // Closes TestComplete
      // Releases COM objects

See Also

Project Property
Integration Object
Working With TestComplete via COM - Overview

Highlight search results