Dim msg As String = "layouts and viewports " & vbCrLf Dim localdoc As Document = Application.DocumentManager.MdiActiveDocument Dim localdb As Database = localdoc.Database Dim ed As Editor = localdoc.Editor Dim lm As LayoutManager = LayoutManager.Current Dim currentlayout As String = lm.CurrentLayout Dim layoutcount As Integer = 0 Dim vptotal As Integer = 0 Dim vponlayout As Integer = 0 Using tr As Transaction = localdb.TransactionManager.StartTransaction Dim layoutDict As DBDictionary = DirectCast(tr.GetObject(localdb.LayoutDictionaryId, OpenMode.ForRead), DBDictionary) For Each entry As DBDictionaryEntry In layoutDict Dim lo As Layout = CType(entry.Value.GetObject(OpenMode.ForRead), Layout) If lo.LayoutName <> "Model" Then layoutcount += 1 lm.CurrentLayout = lo.LayoutName Dim vpids As ObjectIdCollection = lo.GetViewports() vponlayout = 0 For Each objid As ObjectId In vpids Dim vp As Viewport = TryCast(objid.GetObject(OpenMode.ForRead), Viewport) If vp IsNot Nothing Then If vp.Number <> -1 And vp.Number <> 1 Then vponlayout += 1 vptotal += 1 ed.WriteMessage(vbLf & "{0} - name - {1} - number", lo.LayoutName, vp.Number) End If End If Next End If Next tr.Abort() End Using lm.CurrentLayout = currentlayout msg = msg & "layouts " & layoutcount & vbCrLf msg = msg & "viewports " & vptotal & vbCrLf MsgBox(msg)