Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Developer's Guide

Instantiate an XML DOM Object (Visual Basic)

There are two ways to instantiate an XML DOM object in Visual Basic. One way is to create the object at compile time, as follows:

Dim objXMLDoc As New DOMDocument50

You can also create the object at run time, as follows:

Dim objXMLDoc 
Set objXMLDoc = New DOMDocument50

In this demonstration we illustrate both ways of creating a XML DOM instance.

This tutorial uses or creates the following files:

File Description
Source: InstantiateDOM.frm Visual Basic source code.
Output Output from the application.

To create the InstantiateDOM Visual Basic Project

  1. Create a Visual Basic project and set a reference to MSXML 5.0. For detailed instructions on how to do this, see Set Up My Visual Basic Project.
  2. Name the project InstantiateDOMProj.

Next, we'll add the source code for the InstantiateDOM project.