As long as the variable is not typed as object
Dim xmlDocument as MSXML2.DOMDocument
Set xmlDocument = CreateObject("MSXML2.DOMDocument")
is the same as
Dim xmlDocument as MSXML2.DOMDocument
Set xmlDocument = New MSXML2.DOMDocument
both use early binding. Whereas
Dim xmlDocument as Object
Set xmlDocument = CreateObject("MSXML2.DOMDocument")
uses late binding. See MSDN here.
When you’re creating externally provided objects, there are no differences between the New operator, declaring a variable As New, and using the CreateObject function.
New requires that a type library is referenced. Whereas CreateObject uses the registry.
CreateObject can be used to create an object on a remote machine.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…