Set an Object Repositories List as Default for All New Actions
Source code
'This example opens a test, configures an action's object repositories collection
'and saves the test.
'There is no unsaved test currently open in UFT One.
'For more information, see the example for the Test.SaveAs method.

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtRepositories 'As QuickTest.ObjectRepositories ' Declare an action's object repositories collection variable
Dim lngPosition

' Open UFT One
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Launch UFT One
qtApp.Visible = True ' Set UFT One to be visible

' Open a test and get the "Login" action's object repositories collection
qtApp.Open "C:\Tests\Test1", False, False ' Open a test
Set qtRepositories = qtApp.Test.Actions("Login").ObjectRepositories ' Get the object repositories collection object of the "Login" action

' Add MainApp.tsr if it's not already in the collection
If qtRepositories.Find("C:\MainApp.tsr") = -1 Then ' If the repository cannot be found in the collection
    qtRepositories.Add "C:\MainApp.tsr", 1 ' Add the repository to the collection
End If

' If InnerWnd.tsr is moved down the list - place it back at position 1
If qtRepositories.Count > 1 And qtRepositories.Item(2) = "C:\InnerWnd.tsr" Then ' If there's more than one object repository and InnerWnd.tsr is in position 2
    qtRepositories.MoveToPos 1, 2 ' Switch between the first two object repositories
End If

' If Debug.tsr is in the collection - remove it
lngPosition = qtRepositories.Find("C:\Debug.tsr") ' Try finding the Debug.tsr object repository
If lngPosition <> -1 Then ' If the object repository was found in the collection
    qtRepositories.Remove lngPosition ' Remove it
End If

' Set the new object repository configuration as the default for all new actions
qtRepositories.SetAsDefault ' Set object repositories associated with the "Login" action as the default for all new actions

'Save the test and close UFT One
qtApp.Test.Save ' Save the test
qtApp.Quit ' Quit UFT One

Set qtRepositories = Nothing ' Release the action's shared repositories collection
Set qtApp = Nothing ' Release the Application object