View Single Post
 
Old 12-29-2011, 08:43 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default XML parsing & Object variable not set (Error 91)

Unknown error:
Object variable not set (Error 91)

Even after looking at the help document, I cannot figure out why the codes are wrong:

xmlParsing-error(ObjectVariableNotSet).zip
Please see my attachment. Thanks!

Code:
Sub loadXML()

Dim xmlDoc As MSXML2.DOMDocument
Set xmlDoc = CreateObject("MSXML2.DOMDocument.3.0")
xmlDoc.Load ("C:\Users\Tin\Desktop\teacher_halloween.xml")

Dim r As Integer
r = 1
Do
For v = 0 To xmlDoc.getElementsByTagName("Value").Length Step 3
    Cells(r, 1).Value = xmlDoc.getElementsByTagName("Value")(v).Text
    r = r + 1
Next v
Loop Until r = xmlDoc.getElementsByTagName("Time").Length - 1

Set xmlDoc = Nothing
End Sub
Reply With Quote