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