VBA - Reference Microsoft XML, v6.0 DOMDocument60.async

billbrunt

Board Regular
Joined
Jul 17, 2009
Messages
178
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
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
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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