In VBA how do you read an XML file multiple times?

dribdas

New Member
I have a VBA application where I want to read an XML file multiple times. The XML parser code that is called looks like this:\[code\]Set XmlDoc = CreateObject("MSXML.DOMDocument")XmlDoc.async = FalseXmlDoc.validateOnParse = TrueIf Not FileSys.FileExists(XmlFile) Then Exit SubIf Not XmlDoc.Load(XmlFile) Then Debug.Print XmlDoc.parseError.ErrorCode & " " & XmlDoc.parseError.reason Exit SubEnd If' Process the XML ...Set XmlDoc = Nothing\[/code\]This works the first time I access the file. On subsequent accesses though, I get an error that reads "The process cannot access the file because it is being used by another process". I read that there is no explicit way to clean up an MSXML.DOMDocument object. In other words, you can't do XmlDoc.Close. The best you can do is to set XMLDoc to Nothing. But in my case, that does not appear to do the trick.Anybody know how to solve this problem?
 
Back
Top