title: AutoExport Run Results from UFT Function
body: <p>I am running an automated test script using UFT 12.52. I am wondering if there is a way to export results from within a function in the UFT Script. The idea is to call the function and export the run results. </p>
  
  <p>I can do it externally by creating a .vbs file which launches the script in uft and runs and exports the result, but i cannot figure out how to do it from within a UFT Script as function. </p>
  
  <p>Below is my code for exporting results externally. </p>
  
  <p>Thanks</p>
  
  <pre><code>Dim qtApp 
  Dim qtTest 
  Dim qtResultsOpt 
  Dim qtAutoExportResultsOpts 
  
  Set qtApp = CreateObject("QuickTest.Application") 
  qtApp.Launch 
  qtApp.Visible = True 
  
  
  qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
  
  qtApp.Options.Run.RunMode = "Fast"
  qtApp.Options.Run.ViewResults = False
  
  qtApp.Open "Z:\D:\paperlessEnhancements\", True 
  
  
  Set qtTest = qtApp.Test
  qtTest.Settings.Run.IterationMode = "rngIterations" 
  qtTest.Settings.Run.StartIteration = 1
  qtTest.Settings.Run.EndIteration = 1
  qtTest.Settings.Run.OnError = "NextStep" 
  
  Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") 
  qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" n
  
  Set qtAutoExportResultsOpts = qtApp.Options.Run.AutoExportReportConfig
  qtAutoExportResultsOpts.AutoExportResults = True 
  qtAutoExportResultsOpts.StepDetailsReport = True 
  qtAutoExportResultsOpts.DataTableReport = True 
  qtAutoExportResultsOpts.LogTrackingReport = True
  qtAutoExportResultsOpts.ScreenRecorderReport = True
  qtAutoExportResultsOpts.SystemMonitorReport = False 
  qtAutoExportResultsOpts.ExportLocation =
  "C:\Documents and Settings\All  Users\Desktop" 
  qtAutoExportResultsOpts.UserDefinedXSL = "C:\Documents and Settings\All 
  Users\Desktop\MyCustXSL.xsl" 
  qtAutoExportResultsOpts.StepDetailsReportFormat = "UserDefined" 
  qtAutoExportResultsOpts.ExportForFailedRunsOnly = True 
  
  qtTest.Run qtResultsOpt 
  
  MsgBox qtTest.LastRunResults.Status 
  qtTest.Close 
  Set qtResultsOpt = Nothing
  Set qtTest = Nothing 
  Set qtApp = Nothing
  Set qtAutoExportSettings = Nothing 
  </code></pre>
  
  <p>I also tried this : </p>
  
  <pre><code>Dim qtResultsOpt 
  Dim qtAutoExportResultsOpts 
  
  
  Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") 
  qtResultsOpt.ResultsLocation = "C:\Temp\Notepad1" 
  Set qtResultsOpt = Nothing
  </code></pre>