title: How to Associate Static vbs file to Test in UFT and save it
body: <p>I've 200 UFT (14) tests in ALM for which i need to associate 10 function libraries each, save the test back to ALM (11.53) and check in the Test in Test Plan.</p>
  
  <p><b>Is there any way to do this ?</b></p>
  
  <p>I know that there are 4 ways to associate vbs files to a Test. </p>
  
  <p>1) By using ‘File > Settings > Resources > Associate Function Library’ option in QTP.</p>
  
  <p>2) By using Automation Object Model (AOM).</p>
  
  <p>3) By using ExecuteFile method.</p>
  
  <p>4) using LoadFunctionLibrary method.</p>
  
  <pre><code>    In that Method - 3, 4 --&gt; has association only in Runtime (taking long time to start 
  the execution ~ 2 mins per execution)
  
      Method - 2 --&gt; needs to trigger execution from local. I tried this by using the below 
  code but the Test is not getting saved back to ALM.
  
      Method - 1 --&gt; Better approach, but can't do it manually for all 200 tests
  </code></pre>
  
  <p>Below is the code</p>
  
  <pre><code>Set objCon = CreateObject("TDApiOle80.tdconnection")
  objCon.InitConnectionEx URL
  objCon.Login User, Pass
  objCon.Connect Domain, Project
  
  gstrRelativePath = "[ALM] Subject\Automation Development\Training"
  
  Set gobjQtpApp = CreateObject("QuickTest.Application")
  gobjQtpApp.Open gstrRelativePath &amp; "\Test"  
  
  Set objQtpSettings = gobjQtpApp.Test.Settings
  Set objQtpLibraries = objQtpSettings.Resources.Libraries
  objQtpLibraries.RemoveAll
  objQtpLibraries.Add "Support Libraries\" &amp; objFile.Name
  gobjQtpApp.Test.Save
  </code></pre>