Microsoft xml v6.0 not working in excel 2013

moe0303

Board Regular
Joined
Dec 2, 2009
Messages
61
Related thread: http://www.mrexcel.com/forum/excel-questions/783092-new-computer-3.html

Hello,

I have a weird issue. I have spreadsheet with some macros that parse xml files and presents the data in relevant columns. The code was written in excel 2010 and works fine in that environment. When I try opening the file in 2013, I get a "User defined type not defined" error. If I change the reference to xml v3.0 instead of v6.0 it gets a little farther but eventually fails as well.

The code highlighted for the above error is:
Code:
Dim xmlFile As New MSXML2.DOMDocument
I tried changing DOMDocument to DOMDocument60, but also got errors (documented in the related thread). Internet searches have said something about they way DOMDocuments are exposed in 2013 is different. I'm not sure what any of that means. Have any of you guys ever heard of this problem?

-Moe
 
It just occurred to me that it might just be an option in excel 2013 or something. Do you think that is possible?

I didn't write the code, but I am trying to figure out why it won't work in this environment.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I'm not Coder, so I'm not sure how to do that, but if you feel it is simple enough to walk me through it, I'm willing to try.

Since the other 2 references you've tried went through without an error, then you need to use the updated object for that library. Unfortunately, if you are not a coder it will be very difficult for you to troubleshot and make changes.

Maybe if you post your code we can walk you though it. It may still be very difficult since the errors you describe can happen for 1000s of reasons, but right now without even seeing your code it's pointless to even talk about it.
 
Upvote 0
I will try to post the code. It is a lot of code altogether, but I can isolate the portions giving me the error. I will try to do this over the weekend.
 
Upvote 0
I will try to post the code. It is a lot of code altogether, but I can isolate the portions giving me the error. I will try to do this over the weekend.

This is a chunk of the code. Let me know if you want me to post the whole thing.

Code:
Sub Main()
    Dim vFilename As Variant
    Dim vArray As Variant
    Dim vSTIGArray As Variant
    Dim xmlFile As New MSXML2.DOMDocument
    Dim xGroupNodeList As IXMLDOMNodeList
    Dim xRefNodeList As IXMLDOMNodeList
    Dim xCheckNodeList As IXMLDOMNodeList
    Dim xCurrentNode As IXMLDOMNode
    Dim xCCIDNodeList As IXMLDOMNodeList
    Dim sCCDate As Date
    Dim sCCID As String
    Dim sCCIAC As String
    Dim sCCtitle As String
    Dim sVID As String
    Dim sSTIGID As String
    Dim sSCAPID As String
    Dim sSTIG As String
    Dim sSTIGTitle As String
    Dim sSTIGOld As String
    Dim sSeverity As String
    Dim sVersion As String
    Dim sRelease As String
    Dim sGroupTitle As String
    Dim sRuleTitle As String
    Dim sDescription As String
    Dim sFix As String
    Dim sCheck As String
    Dim sDiscussion As String
    Dim sIAC As String
    Dim sTmp As String
    Dim bContinue As Boolean
    Dim r As Range
    Dim bVersionCheck As Boolean
    Dim dBenchmarkDate As Date
    Dim dBenchmarkDateOld As Date
    Dim lRow As Long
    Dim lRow1 As Long
    Dim lRowFirst As Long
    Dim bFound As Boolean
    Dim i As Long
    
       
    'iSelection = MsgBox("Continue with STIG Import?", vbYesNo)
       
    'If iSelection = 6 Then
    
    Application.ScreenUpdating = False
    'Sheets("Checklist Summary").Unprotect
    Sheets("CCI Mapping").Visible = xlSheetVisible
    
        vFilename = Application.GetOpenFilename("XCCDF.xml (*.xml), *.xml", , "Choose STIG to Import", MultiSelect:=True)
            
        Application.StatusBar = "Importing STIG(s) Please Wait........."
        
        Sheets("Checklist").Select
         
        If IsArray(vFilename) Then
            
            For icount = 1 To UBound(vFilename)
               
                Set xmlFile = CreateObject("MSXML2.DOMDocument")
                xmlFile.async = False
                xmlFile.validateOnParse = False
                xmlFile.Load (CStr(vFilename(icount)))
                
                If (xmlFile.parseError.errorCode <> 0) Then
                   Set myErr = xmlFile.parseError
                   MsgBox ("You have error " & myErr.reason)
                Else
                    
                    sSTIG = xmlFile.selectSingleNode("Benchmark").selectSingleNode("title").nodeTypedValue
                    sVersion = xmlFile.selectSingleNode("Benchmark").selectSingleNode("version").nodeTypedValue
                    sRelease = xmlFile.selectSingleNode("Benchmark").selectSingleNode("plain-text").nodeTypedValue
                    Set xGroupNodeList = xmlFile.selectSingleNode("Benchmark").SelectNodes("Group")
                    
                    bContinue = True
                    bVersionCheck = False
                  
                    
                    
                    'On Error Resume Next
                    'lRow = ActiveSheet.Columns("D").Find(sSTIG).Row
                    'On Error GoTo 0
                   
                    sSTIGTitle = sSTIG
                    sSTIG = sSTIG & " Version: " & sVersion & " " & sRelease
                    
                    vArray = Split(sRelease, " Benchmark Date: ")
                        dBenchmarkDate = vArray(1)
                        sRelease = vArray(0)
                    
                    'Check if a version of this STIG has already been imported
                    Sheets("Checklist").Select
                    'Application.StatusBar = "Checking for other imported versions of " & sSTIGTitle & ". Please Wait........."
                        
                    With ActiveSheet
                        Set rLastCell = .Cells(.Rows.Count, "D").End(xlUp)
                        If IsEmpty(rLastCell) Then
                            'do nadda
                        Else
                            Set rLastCell = rLastCell.Offset(1, 0)
                        End If
                    End With
                    
                    lRow = 4
                    sTmp = ""
                  
                    Do While lRow < rLastCell.Row And bContinue = True
                    
                        
                        sSTIGOld = ActiveSheet.Cells(lRow, "D").Value
                        If InStr(sSTIGOld, sSTIGTitle & " Version: ") <> 0 Then
                            vArray = Split(sSTIGOld, " Benchmark Date: ")
                            dBenchmarkDateOld = vArray(1)
                                
                            If StrComp(dBenchmarkDate, dBenchmarkDateOld) = 0 Then
                                bContinue = False
                                MsgBox (sSTIG & " has already been imported.")
                            ElseIf dBenchmarkDate < dBenchmarkDateOld Then
                                bContinue = False
                                MsgBox (sSTIGOld & ", which is newer than " & sSTIG & ", has already been imported.")
                            ElseIf dBenchmarkDate > dBenchmarkDateOld Then
                                bContinue = True
                                bVersionCheck = True
                            End If
                            
                            If sSTIGOld <> "" And InStr(sTmp, sSTIGOld) = 0 Then
                                sTmp = sTmp & sSTIGOld & "|"
                            End If
                        End If
 
Upvote 0
From this link: https://social.technet.microsoft.co...2b76e3f7f/microsoft-xml-v60-msxml6dll-and-vba

"While testing an Excel workbook in Windows 8 Consumer Preview (build 8250) I got an error saying that "MSXML2.DOMDocument" is not defined. The workbook is currently running in Windows 7 without problems.
It happens that, in win8, Microsoft XML, v6.0 does not expose the DomDocument interface, only DOMDocument60; msxml6.dll version is 8.110.8250.0
On the other hand Microsoft XML, v3.0 exposes DomDocument, DomDocument26 and DomDocument30; version is 6.30.8250.0
With other versions of Windows, like 7 and XP, both msxml3.dll and msxml6.dll expose DomDocument, DomDocument30 and DomDocument60, among others. We have some workbooks with v3, others with v6, always using the "basic" DomDocument."

Could this be related to the issue a I'm having? In my case, the code works fine on a Windows 7 system using excel 2010 but not on a Windows 10 system using excel 2013.
 
Upvote 0
Can you change these 3 parts and let me know what you get?

--------------------------------------------------------------------

Dim xmlFile As MSXML2.DOMDocument60


---------------------------------------------------------------------------


Set xmlFile = New MSXML2.DOMDocument60
xmlFile.async = False
xmlFile.validateOnParse = False


xmlFile.setProperty "SelectionNamespaces", "xmlns:a='http://schemas.microsoft.com/search/local/ws/rest/v1'"


xmlFile.Load (CStr(vFilename(icount)))






-----------------------------------------------------------------------------


sSTIG = xmlElement.SelectSingleNode("/a:Benchmark/a:title").Text
 
Upvote 0
Can you change these 3 parts and let me know what you get?

--------------------------------------------------------------------

Dim xmlFile As MSXML2.DOMDocument60


---------------------------------------------------------------------------


Set xmlFile = New MSXML2.DOMDocument60
xmlFile.async = False
xmlFile.validateOnParse = False


xmlFile.setProperty "SelectionNamespaces", "xmlns:a='http://schemas.microsoft.com/search/local/ws/rest/v1'"


xmlFile.Load (CStr(vFilename(icount)))






-----------------------------------------------------------------------------


sSTIG = xmlElement.SelectSingleNode("/a:Benchmark/a:title").Text

Runtime error '424': Object Required

on
Code:
sSTIG = xmlElement.SelectSingleNode("/a:Benchmark/a:title").Text

But it did allow me to select a file.
 
Upvote 0
This is the code with the changes requested.

Code:
Sub Main()
    Dim vFilename As Variant
    Dim vArray As Variant
    Dim vSTIGArray As Variant
    Dim xmlFile As New MSXML2.DOMDocument60
    Dim xGroupNodeList As IXMLDOMNodeList
    Dim xRefNodeList As IXMLDOMNodeList
    Dim xCheckNodeList As IXMLDOMNodeList
    Dim xCurrentNode As IXMLDOMNode
    Dim xCCIDNodeList As IXMLDOMNodeList
    Dim sCCDate As Date
    Dim sCCID As String
    Dim sCCIAC As String
    Dim sCCtitle As String
    Dim sVID As String
    Dim sSTIGID As String
    Dim sSCAPID As String
    Dim sSTIG As String
    Dim sSTIGTitle As String
    Dim sSTIGOld As String
    Dim sSeverity As String
    Dim sVersion As String
    Dim sRelease As String
    Dim sGroupTitle As String
    Dim sRuleTitle As String
    Dim sDescription As String
    Dim sFix As String
    Dim sCheck As String
    Dim sDiscussion As String
    Dim sIAC As String
    Dim sTmp As String
    Dim bContinue As Boolean
    Dim r As Range
    Dim bVersionCheck As Boolean
    Dim dBenchmarkDate As Date
    Dim dBenchmarkDateOld As Date
    Dim lRow As Long
    Dim lRow1 As Long
    Dim lRowFirst As Long
    Dim bFound As Boolean
    Dim i As Long
    
       
    'iSelection = MsgBox("Continue with STIG Import?", vbYesNo)
       
    'If iSelection = 6 Then
    
    Application.ScreenUpdating = False
    'Sheets("Checklist Summary").Unprotect
    Sheets("CCI Mapping").Visible = xlSheetVisible
    
        vFilename = Application.GetOpenFilename("XCCDF.xml (*.xml), *.xml", , "Choose STIG to Import", MultiSelect:=True)
            
        Application.StatusBar = "Importing STIG(s) Please Wait........."
        
        Sheets("Checklist").Select
         
        If IsArray(vFilename) Then
            
            For icount = 1 To UBound(vFilename)
               
                Set xmlFile = New MSXML2.DOMDocument60
                xmlFile.async = False
                xmlFile.validateOnParse = False
                
                xmlFile.setProperty "SelectionNamespaces", "xmlns:a='http://schemas.microsoft.com/search/local/ws/rest/v1'"

                xmlFile.Load (CStr(vFilename(icount)))
                'xmlFile.Load (CStr(vFilename(icount)))
                
                If (xmlFile.parseError.errorCode <> 0) Then
                   Set myErr = xmlFile.parseError
                   MsgBox ("You have error " & myErr.reason)
                Else
                    
                    sSTIG = xmlElement.SelectSingleNode("/a:Benchmark/a:title").Text
                    sVersion = xmlFile.SelectSingleNode("Benchmark").SelectSingleNode("version").nodeTypedValue
                    sRelease = xmlFile.SelectSingleNode("Benchmark").SelectSingleNode("plain-text").nodeTypedValue
                    Set xGroupNodeList = xmlFile.SelectSingleNode("Benchmark").SelectNodes("Group")
                    
                    bContinue = True
                    bVersionCheck = False
                  
                    
                    
                    'On Error Resume Next
                    'lRow = ActiveSheet.Columns("D").Find(sSTIG).Row
                    'On Error GoTo 0
 
Upvote 0

Forum statistics

Threads
1,215,636
Messages
6,125,952
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top