runtime error 91 Object Variable or With Block Variable not set
the file Test.docm exists, the XML object library in references already there. i cannot figure out what it causing this.
thanks.
VBAMicrosoft Excel
Last Comment
Martin Liss
8/22/2022 - Mon
crystal (strive4peace) - Microsoft MVP, Access
on the thread you referenced, the last comment (DrTribos) was to add statements to skip errors and he gives an example. Perhaps there is no object there.
Martin Liss
Do you have something like this in the sub?
Dim oNode As IXMLDOMNode
Dim oNodeList As IXMLDOMNodeList
Flora Edwards
ASKER
Hi Martin,
i this is the whole UDF
Public Function CountItemsInXML(ByVal sXML As String) As Long Dim oNode As MSXML2.IXMLDOMNode Dim oNodeChild As MSXML2.IXMLDOMNode Dim oNodeList As MSXML2.IXMLDOMNodeList Dim oXMLDoc As MSXML2.DOMDocument Dim iAttribute As Long Dim iCount As Long Set oXMLDoc = New MSXML2.DOMDocument oXMLDoc.loadXML sXML Set oNodeList = oXMLDoc.SelectNodes("/customUI") 'Nodes: CustomUI/Ribbon/Tabs/Tab/Groups For Each oNode In oNodeList.Item(0).ChildNodes.Item(0).ChildNodes.Item(0).ChildNodes.Item(0).ChildNodes For Each oNodeChild In oNode.ChildNodes If oNodeChild.Attributes.Length > 1 Then iCount = iCount + 1 End If Next Next CountItemsInXML = iCountEnd Function