Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest (if not launched)
qtApp.Visible = True ' Make it visible
' Save the current test and open a new one if needed
If qtApp.Test.Modified Then ' If the test was modified
If qtApp.Test.IsNew Then ' If it is a new test (untitled)
qtApp.Test.SaveAs "C:\Temp\TempTest" ' Save it with a temporary name (override existing temporary test)
Else ' If the test exists (has a name)
qtApp.Test.Save ' Save the changes
End If
End If
If Not qtApp.Test.IsNew Then ' If the current test is not new
qtApp.New ' Open a new test
End If
Set qtApp = Nothing ' Release the Application object