KongGulerod
New Member
- Joined
- Feb 23, 2017
- Messages
- 17
- Office Version
- 2013
- Platform
- Windows
Hi
I have a script that reads XML files, one file at at time and joins them to a sheet. It works. The function that does the actual reading of the XML looks like this:
I would love to limit the reading of files to be files that has been changed in 2017. How can I do this. I need to add some testing of the file date in the IF statement, but how and where?
Kind regards KongGulerod
I have a script that reads XML files, one file at at time and joins them to a sheet. It works. The function that does the actual reading of the XML looks like this:
Code:
Private Function ReadXmlFile(filename As String, ws As Worksheet, rowNo As Integer) As Boolean
Dim objXML As New MSXML2.DOMDocument
Dim point As IXMLDOMNode
Dim result As IXMLDOMNodeList
Dim strXml As String
Dim arrFields As Variant
Dim value As String
Dim i As Integer
On Error GoTo ErrorHandler
arrFields = Split(Globals.XmlFields, ":")
'Load XML from file
If objXML.Load(filename) Then
strXml = objXML.XML
For i = 0 To UBound(arrFields)
value = objXML.SelectSingleNode("/my:myFields/my:" & arrFields(i)).Text
If isDateValue(value) Then value = Left(value, 10)
ws.Cells(rowNo, i + 1) = value
Next i
Else
notProcessedXml = notProcessedXml & vbCrLf & filename
ReadXmlFile = False
End If
ReadXmlFile = True
Exit Function
ErrorHandler:
notProcessedXml = notProcessedXml & vbCrLf & filename
ReadXmlFile = True
End Function
I would love to limit the reading of files to be files that has been changed in 2017. How can I do this. I need to add some testing of the file date in the IF statement, but how and where?
Kind regards KongGulerod