WindowTitle Example [AEC Base Automation Reference: AecXBase]

AEC Auto

WindowTitle Example

Sub Example_WindowTitle()

    ' This example cycles through the documents collection
    ' and uses the WindowTitle property to create a list of all open documents.

    Dim DOC As AecBaseDocument
    Dim aecApp As New AecBaseApplication
    Dim msg As String
    
    ' Initialize the Aec Base application object
    aecApp.Init ThisDrawing.Application
    
    ' If there are no open documents, then exit
    If aecApp.Documents.count = 0 Then
        MsgBox "There are no open documents!"
        Exit Sub
    End If
    
    msg = vbCrLf & vbCrLf   ' Start with a space
    
    ' Cycle through all open drawings and get the window title of each drawing
    For Each DOC In aecApp.Documents
        msg = msg & DOC.WindowTitle & vbCrLf
    Next
    
    ' Display a list of open drawings
    MsgBox "The open drawing titles are: " & msg

End Sub