Reputation: 388
I use a with statement in VBA like this:
With New MSXML2.DOMDocument60
'Some statements
end with
and I have got a sub like this:
Private Sub anyfunction(ByVal par_document As MSXML2.DOMDocument60)
end sub
Is there a way to use the the temporary object as the parameter for the anyfunction or do I have to create a variable with "Dim" in order to use the anyfunction?
Upvotes: 2
Views: 95
Reputation: 2686
If the object provides a reference to it self, use that. ForMSXML2.DOMDocument60
you can use.SelectSingleNode("/")
or use a child-object with a reference to the parent-object. (e.g..documentElement.ownerDocument
or.childNodes(0).parentNode
, but they need a XML-Document loaded.)
Or the opposite (parent to child) forDao.Recordset
use.Parent.RecordSets(.Name)
.
With New MSXML2.DOMDocument60
.Load("xmlfile")
anyfunction(.SelectSingleNode("/"))
end with
Upvotes: 0