Dear Mac,
Are you reffering to shapes dropped not coming from your own stencil ?
You have several ways for this.
First :
You could check if shape has a master by a boolean function including a loop over all shapes and check something like
If Not shp.master Is Nothing Then
If shape has no master this line will raise an error up, in the handling error, you could remove the said shape.
Second :
The alternative I have considered by my side
I have added in every shapes for each stencil, a section UsercellsDefined that contains reference. (in my case sql Id)
When I loop over all shapes I check if shape has a reference, in case of not, delete it.