Access 2003: Running MSXML VBA in Module - Run-time error '13' -Ty

S

SHC

Hi all,
I copied the Bisual Basic code of MSXML IXMLDOMNodeList from MSDN and
adopted it to my Microsoft Access 2003 for VBA execution.

I ran the attached MSXML code in my Access2003 Module and I got: Microsoft
Visual Basic Run-time error '13' - Type mismatched. This error lies in the
following code:
Set str = "The node list has " & objNodeList.length & _
" item." & & vcCrLf

Please help and advise me how to correct the error in my coding and make it
working for me.

Thanks in advance,
SHC

///////----Module1---////////
Sub getNodeList()

' The following Microsoft® Visual Basic® example uses books.xml
' to create an IXMLDOMNodeList and display its XML.
' Supports iteration through the live collection, in addition to
' indexed access.


Dim xmlDoc As New MSXML2.DOMDocument50
Dim currNode As IXMLDOMNode

Set xmlDoc = New MSXML2.DOMDocument50

xmlDoc.async = False
xmlDoc.Load ("C:\MSXML-msdn\books.xml")

If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox ("You have error " & myErr.reason)
Else
Set objNodeList = xmlDoc.getElementsByTagName("author")
Dim str
Set str = "The node list has " & objNodeList.length & _
" items." & vbCrLf
MsgBox (str)
Dim x As Long
x = 1
For x = 1 To objNodeList.length
str = str & CStr(x) & ": " & objNodeList.Item(x - 1).XML & vbCrLf
Next
MsgBox str
End If


End Sub
 
A

Alex Dybenko

Hi,
you don't need to use set with string varible, just remove it:

str = "The node list has " & objNodeList.length & _
" item." & & vcCrLf
 
K

Klatuu

How Interesting, I notice 2 ampersands seperated by a space (& &). Maybe
that is a typo in your post. It errored on trying to recreate it. Also, you
don't need the Set statement.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top