[CONNECT VBA] Using NamedGroup elements to increase select performance

With large drawing files we may experience VBA performance issues while selecting individually a large number of elements. Depending on the size and type this may take minutes until all elements are selected.
I would like to point to NamedGroup elements to help to increase performance extremely.
The idea is to add each individual element to one single NamedGroup and finally "select" this NamedGroup. 
Tests are showing that in most cases the time used to select all elements is less than 3 seconds.

Here a small code example to demonstrate the use of NamedGroup elements to select all selectable elements from active model:

 

Sub SelectElementsWithNG()
Dim ee As ElementEnumerator
Dim ngTemp As NamedGroupElement
Dim t1, t2
    t1 = Timer
    ' First unselect all elements
    ActiveModelReference.UnselectAllElements
    
    ' delete named group from previous starts
    CadInputQueue.SendKeyin "NamedGroup Delete TempNGGroup"
    
    ' create a new temporary named group
    Set ngTemp = ActiveModelReference.AddNewNamedGroup("TempNGGroup")
    
    Set ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While ee.MoveNext
        ' Add each element to the named group
        ngTemp.AddMember ee.Current
    Loop
    
    ' Select all elements from named groups
    ngTemp.SelectElements msdMemberTraverseSimple
    
    ' delete temporary named group
    ActiveModelReference.RemoveElement ngTemp
    t2 = Timer
    Debug.Print "Time spent to select all elements: " & CStr(t2 - t1) & " sec."
End Sub

With small changes to the previous code example the same approach can be used to invert a previous selection. The following code example is adding all not selected elements into a new named group and is selecting this group:

Sub InvertSelectedElementsWithNG()
Dim ee As ElementEnumerator
Dim ngTemp As NamedGroupElement
Dim t1, t2
    t1 = Timer
    
    ' delete named group from previous starts
    CadInputQueue.SendKeyin "NamedGroup Delete TempNGGroup"
    
    ' create a new temporary named group
    Set ngTemp = ActiveModelReference.AddNewNamedGroup("TempNGGroup")
    
    Set ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While ee.MoveNext
       If Not ActiveModelReference.IsElementSelected(ee.Current) Then
        ngTemp.AddMember ee.Current
       End If
    Loop
    'unselect all elements
    ActiveModelReference.UnselectAllElements
    
    ' Select all elements from named groups to invert previosu selection
    ngTemp.SelectElements msdMemberTraverseSimple
    
    ' delete temporary named group
    ActiveModelReference.RemoveElement ngTemp
    t2 = Timer
    Debug.Print "Time spent to invert selection: " & CStr(t2 - t1) & " sec."
End Sub

Please find attached another example to demonstrate the use of NamedGroups to increase performance with selecting elements.
This example allows the user to select a date/time range of DateLastmodified property to add to Selection.

DateChanged.zip
Anonymous