How can I pass a callable object to another function/subroutine without calling/invoking it?
<p>I'm using VBA 7.1 in MS Office 2013. I'm trying to interact with a function in JavaScript (or an interface of it created using as close as possible in shortened code <code>CreateObject("HtmlFile").ParentWindow.close</code> - similar to <code>window.close</code> in JavaScript). The problem is, I'm trying to pass it to another function, but it keeps calling the actual <code>window.close</code> function in JavaScript <em>as I pass it</em>. This is where it gets weird: it doesn't get invoked in a few specific built-in functions.</p>

<pre><code>CStr(obj) ' Invokes the interface; window close dialog appears
VarType(obj) ' Invokes the interface; window close dialog appears
IsEmpty(obj) ' Invokes the interface; window close dialog appears
TypeName(obj) ' Doesn't invoke the interface; returns "Object"
IsObject(obj) ' Doesn't invoke the interface; returns True
</code></pre>

<p>Is there a way to pass it around <em>without</em> invoking it?</p>

<p><strong>EDIT:</strong> You can replicate the setup using this:</p>

<pre><code>With CreateObject("HtmlFile")
    .ParentWindow.ExecScript "obj = window.close"
    Set obj = .ParentWindow.obj
End With
</code></pre>