Minimalistic working example:
Lib.vbs:
Option Explicit
Function Twice(n)
Twice = n + n
End Function
Main.vbs:
Option Explicit
Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")
ExecuteGlobal goFS.OpenTextFile(".\lib.vbs").ReadAll()
Dim fpTwice : Set fpTwice = GetRef("Twice")
WScript.Echo fpTwice(42)
Output:
cscript main.vbs
84
The error message "... runtime error: Invalid procedure call or argument: 'GetRef'" indicates that the (importing of the) function library is to blame.
Update:
I think that it is plausible to assume that the VBScript engine keeps a table associating sub/function/method names with callable code to be able to do literal/direct calls:
n = Twice(11)
and that GetRef("Twice") accesses this table. So I would never expect an indirect/'function pointer' call or a GetRef() to fail when the literal invocation succeeds.
But according to this and that, there are at least four ways to 'import' libraries/modules into QTP, and as I don't use QTP I can't rule out, that some (or even all) of these methods do something silly to cause the mis-behaviour you describe.
GetRef
works in plain VBScript. – Blithe