My code works this way:
(if
(ssget "X" '((0 . "INSERt") (410 . "MODEL"))) ; creates an anonymous SelectionSet of all blocks inserted in ModeSpace
(vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object))); expanding this one, in order of evaluation
;it may be write
(setq acad_object (vlax-get-acad-object)) ; a VLA-object representing the running instance of AutoCAD, i.e. the current session
(setq current_drawing (vla-get-ActiveDocument acad_object)); a VLA-object representing current drawing (active drawing, active document - name it as you wish)
(setq ActiveSelectionSet (vla-get-ActiveSelectionSet current_drawing)); the selection created before, with (ssget... ; a VLA-object itself
;this last VLA-object, containing a colection of VLA-objects each representing a block, is passed to iteration function, vlax-for
Now, any VLA-object has a set of properties and/or methods, accessible via ActiveX;
in fact, ActiveDocument is a property of acad_object
ActiveSelectionSet is a property of current_drawing
you can see all available prop./methods of a VLA-object, using (vlax-dump-object #<VLA-OBJECT... )
Each object within ActiveSelectonSet is a vla-object which, of course, has properties and methods
PATH is a property of an external-reference and common blocks doesn't have it
So, if an object tested has PATH property, (vlax-property-available-p blk 'Path), then it is an ER; otherwise it is a block.
For getting the correct name of Dynamic Blocks, (vla-get-EffectiveName blk) should be used instead of (vla-get-Name...