Function library can be associated in design time or run-time depending on the framework used.
To associate the function library at design time
navigate to ‘File > Settings > Resources > Associate Function Library’ option in QTP. Click on '+' button and browse for the file and add it to the Test
To associate the function library at run time, you can use any of the following
1) Automation Object Model (AOM)
'Open QTP
Set objQTP = CreateObject("QuickTest.Application")
objQTP.Launch
objQTP.Visible = True
'Open a test
objQTP.Open "D:\Automation\Test1", False, False
Set objFL = objQTP.Test.Settings.Resources.Libraries
'check if it is already associated, else associate it
If objFL.Find("D:\Automation\FunctionLibrary.vbs") = -1 Then
objFL.Add "D:\Automation\FunctionLibrary.vbs", 1
End
2) using ExecuteFile method.
ExecuteFile "D:\Automation\FunctionLibrary.vbs"
3) using LoadFunctionLibrary method.
LoadFunctionLibrary "D:\Automation\FunctionLibrary.vbs"