Hi -
There is a property DOMDocument.async which when set to true, the default, it is supposed to allow processing to continue and return control to VBA while DOMDocument.load (tried loadXML as well) runs.
Tried a couple of different ways after searching.
One is posted at: https://stackoverflow.com/questions...readystatechange-of-msxml2-domdocument-in-vba
The other is shown below.
Neither returned control.
Thanks in advance for anyone with some tips on this!!
- Bill
There is a property DOMDocument.async which when set to true, the default, it is supposed to allow processing to continue and return control to VBA while DOMDocument.load (tried loadXML as well) runs.
Tried a couple of different ways after searching.
One is posted at: https://stackoverflow.com/questions...readystatechange-of-msxml2-domdocument-in-vba
The other is shown below.
Neither returned control.
Thanks in advance for anyone with some tips on this!!
- Bill
Code:
' http://dailydoseofexcel.com/archives/2009/06/16/reading-xml-files-in-vba/
Sub subTestXML2()
Dim XMLDOC As MSXML2.DOMDocument60
Dim lsLngFirstReadyState As Long
Dim lsLngSecondReadyState As Long
Set XMLDOC = New MSXML2.DOMDocument60
lsStrTiming001 = RPad("Before XMLDOC.Load", 30) & TimeInMS()
XMLDOC.Load "C:\Windows\Panther\MigLog.xml"
Debug.Print XMLDOC.async
XMLDOC.async = False ' https://msdn.microsoft.com/en-us/library/ms761398(v=vs.85).aspx
Debug.Print XMLDOC.async
lsLngFirstReadyState = XMLDOC.readyState
lsStrTiming002 = RPad("After XMLDOC.Load", 30) & TimeInMS()
lsStrTiming003 = "Never ran"
For i = 1 To 10000000
If lsLngFirstReadyState <> XMLDOC.readyState Then
lsLngSecondReadyState = XMLDOC.readyState
lsStrTiming003 = RPad("XMLDOC.readyState changed", 30) & TimeInMS()
i = 10000000
End If
Next i
Debug.Print lsStrTiming001
Debug.Print "lsLngFirstReadyState = " & CStr(lsLngFirstReadyState)
Debug.Print lsStrTiming002
Debug.Print lsStrTiming003
Stop
End Sub
'Read more at http://vbadud.blogspot.com/2008/10/excel-vba-timestamp-milliseconds-using.html#BrMUtpl8xD0iSVOW.99
Public Function TimeInMS() As String
TimeInMS = Strings.Format(Now, "dd-MMM-yyyy HH:nn:ss") & "." & Strings.Right(Strings.Format(Timer, "#0.00"), 2)
End Function