I use VB6 to work with AutoCAD/Civil3D. With the new version 2013 I'm not able to find the viewports. It looks like the TypeOf is missing.
Private Function DeleteViewPorts(ObjectLayouts, arrayHandles)
'Delete Viewports not in the arrayHandles
Dim i As Integer
Dim ent As Object
Dim Handle As String
For i = ObjectLayouts.block.Count - 1 To 0 Step -1
If i < ObjectLayouts.block.Count Then
Set ent = ObjectLayouts.block(i)
If TypeOf ent Is AcadPViewport Or TypeOf ent Is IAcadPViewport Then
Handle = ent.Handle
If InArray(Handle, arrayHandles) < 0 Then
I watch the object ent while it's changing. At the point it reaches a Viewport, the Watch notices it, but the if-statement (the TypeOf statement) doesn't recognize it. In 2012 it works very good.