MicroStation Programming Forum - Need help with VBA Coding and XML
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

Need help with VBA Coding and XML

by
Bentley Communities Legacy Member
Expert

Hi, 

Ive just started working on a small VBA project in Microstation V8i and am looking at trying to use XML files to help populate certain information within the programme. We are developing this within the "VBA Project Manager" of Microstation. 

Currently i have a simple XML file in which i want to read an publish the information within the file to debug. Once i know i can get the programme to do this i can convert this for use in future tasks.

Below is the code i used which is taken from "Learning Microstation VBA" book. As far as i can tell this code is correct however when i try and run the programme i get the following error

Run-time error'91':

Object variable or with block variable not set


Private Sub XML_Load_Click()
    Dim myXML As New MSXML2.DOMDocument
    Dim myXElem As MSXML2.IXMLDOMElement
    Dim myXRecord As MSXML2.IXMLDOMElement
    Dim myXField As MSXML2.IXMLDOMElement
    

    
    myXML.async = False
    myXML.validateOnParse = False
    myXML.Load "C:\Users\ryan.grant02\Desktop\OLE_Wiz\Core_Settings.xml"
    Set myXElem = myXML.documentElement
    For Each myXRecord In myXElem.childNodes
       Debug.Print "***NEW RECORD***"
       For Each myXField In myXRecord.childNodes
           Debug.Print myXField.baseName & ".." & myXField.Text
       Next
    Next
End Sub

The aim is then to convert this to allow me to complete multiple tasks such as populate a drop down menu, settings for the software, limitations of cells etc. 

Any help on this would be appreciated.