none
Procedure with DOMdocument works in Access 2010/windows 7 pro but not in Access 2013/windows 10 RRS feed

  • Question

  • Hello,

    The following procedure works in Access 2010/win 7 pro but not in Access 2013/win 10, references for XML, v6.0 are included in the both cases. (Err. 91 Object variable not set).

    Please help.

    Procedure in a form, in which the user inputs 10 symbols ID (EGN)

    'declarations in the form

    Option Compare Database

    Dim dom As MSXML2.DOMDocument60

     

    'the procedure in question

    Private Sub txtEGN_LostFocus()

    Dim oXml As Object
       
        strEGN = txtEGN.Text
       
    '    On Error GoTo vavezhdane:
        usr = "TRUMF" '' Ïîïúëíåòå Ïîòðåáèòåëñêî èìå íà óíèâåðñèòåòà
        pass = "MF1289" '' Ïîïúëíåòå Ïàðîëà íà óíèâåðñèòåòà
        'id = 9310077666# '' Ïîïúëíåòå ÅÃÍ íà ó÷åíèêà
       
        id = CDbl(strEGN) '' Ïîïúëíåòå ÅÃÍ íà ó÷åíèêà
       
        Set oXml = CreateObject("MSXML2.ServerXMLHTTP")
        oXml.setTimeouts 6000, 6000, 6000, 6000 'çàäàâà ïåðèîä îò 6 ñåêóíäè
        oXml.Open "POST", "http://www2.mon.bg/ws/ws.asmx", False
       
        ' Ñúçäàâàíå íà çàÿâêàòà êúì ñúðâúðà
        Dim xmlRequest As String
       
        xmlRequest = _
            "<?xml version=""1.0"" encoding=""utf-8""?>" & _
            "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
                "<soap:Body>" & _
                "<getStudentDataFromEGN xmlns=""http://www2.mon.bg/"">" & _
                "<intStudentID>" & id & "</intStudentID>" & _
                "<u>" & usr & "</u>" & _
                "<p>" & pass & "</p>" & _
                "</getStudentDataFromEGN>" & _
               "</soap:Body>" & _
            "</soap:Envelope>"
       
        oXml.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
       
        oXml.send CStr(xmlRequest) '' Èçïðàùàíå
       
        Set dom = New MSXML2.DOMDocument60
        dom.loadXML XmlEscape(oXml.responseText)
       
        Dim StudentName1 As String
        Dim StudentName2 As String
        Dim StudentName3 As String
       
        StudentName1 = dom.getElementsByTagName("H").Item(0).Text ' The error appears here!
        StudentName2 = dom.getElementsByTagName("I").Item(0).Text ' Âçèìàíå íà èìåòî îò îòãîâîðà ñúãëàñíî ñïåöèôèêàöèÿòà
        StudentName3 = dom.getElementsByTagName("J").Item(0).Text ' Âçèìàíå íà èìåòî îò îòãîâîðà ñúãëàñíî ñïåöèôèêàöèÿòà
        StudentName = StudentName1 & " " & StudentName2 & " " & StudentName3
    '   MsgBox StudentName ' Âèçóàëèçèðàíå íà èìåòî
       
    '    Exit Sub
    'vavezhdane:
    '    txtIme.SetFocus
    '    txtIme.Text = "Âúâåäåòå èìåòî" ' Âèçóàëèçèðàíå íà èìåòî
    End Sub

    Function XmlEscape(val As Variant) As String
        Dim ret As String
        ret = CStr(val)
        ret = Replace(ret, "&quot;", """")
        ret = Replace(ret, "&apos;", "'")
        ret = Replace(ret, "&lt;", "<")
        ret = Replace(ret, "&gt;", ">")
        ret = Replace(ret, "&amp;", "&")
        XmlEscape = ret
    End Function

    Greetings,

    Nikolay



    Saturday, February 11, 2017 12:41 PM

All replies

  • Hi,

    Which line causes the issue? Please watch the dom object to check if it receives the correct data.

    Since this issue is not related to office object model , I would move this thread into VBA forum.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 13, 2017 7:10 AM
    Moderator
  • Hi Celeste,

    I underlined the line where the error appears!

    Conflict between Windows 10 and Microsoft XML 6.0? I noticed the problem arises also in Office 2010 on Windows 10 machine but not in Office 2010 with Windows 7 pro machine.

    Regards,

    Nikolay  

    Thenks of all,

    The problem was resolved by simple replacement of the refference from Microsoft XML 6.0 to Microsoft XML 3.0 (Also DOMdocument6.0 to DOMdocument)

    Best Regards,

    Nikolay 

    Monday, February 13, 2017 7:49 PM
  • I've never used Microsoft XML.  Is there an option to save the DOM just prior to that command?  This is the first time you are selecting an element.  I suspect the problem is earlier and your not even on the right page.  
    Monday, February 13, 2017 9:27 PM