I doubt you are getting the error on the SelectSingleNode, perhaps that's just a typo in your question?
I suspect you are really getting the failure when trying to access ObjNode.Text
. This is because SelectSingleNode will return Nothing
if it can't find the node requested. So you just need to check the return value before deciding whether to access .Text.
Set ObjXml = Createobject("Microsoft.XMLDOM")
'Presumably you have a step to load the XML here.
Set ObjNode = ObjXml.SelectSingleNode("/soap:Envelope/soap:Body/*/MessageElements/MessageStatus")
If ObjNode Is Nothing Then
MsgBox "Oh no! Failure!"
Else
ResultText = ObjNode.text
End If
Oh, and you can probably shorten your XPath to //MessageStatus
if that element never appears elsewhere in the document.