Questions similar to this appear on the Be Community Forums. This problem appeared in the VBA discussion group.

Q  MicroStation's main window caption, by default, displays the current DGN file name and the active model. Sometimes you may want to change that default to something more meaningful to your colleagues.

DGN File Events

The answers to those questions are solved by creating a VBA project that responds to DGN File Events. We provide a different implementation of subroutine hooks_OnDesignFileOpened that updates the Application.Caption each time the user opens a new DGN file …

Public Sub hooks_OnDesignFileOpened(ByVal fileName As String)
    Debug.Print "Opened design file " & fileName
End Sub

A  Setting the DGN file as the Application.Caption is straightforward, since we have to do little more than copy the name to the caption …

Public Sub hooks_OnDesignFileOpened(ByVal fileName As String)
    Debug.Print "Opened design file " & fileName
    Application.Caption = fileName
End Sub

You may want to do a little more work than that. Perhaps you want just the file title displayed, rather than its full path …

Public Sub hooks_OnDesignFileOpened(ByVal fileName As String)
    Debug.Print "Opened design file " & fileName
    Application.Caption = ParseFileTitle (fileName)
End Sub

ParseFileTitle extracts the file title from the full path. The function is included in the SetMicroStationTitle project.

A  Setting the workspace project name as the Application.Caption is also straightforward. In this case, expand the _USTN_USER or _USTN_PROJECT name …

Public Sub hooks_OnDesignFileOpened(ByVal fileName As String)
    Debug.Print "Opened design file " & fileName
    Dim projectName				As String
    projectName = ActiveWorkspace.ConfigurationVariableValue ("_USTN_PROJECT")
    Application.Caption = projectName
End Sub

Set MicroStation Title VBA Project

The functions above are included in the SetMicroStationTitle project. You can download this ZIP archive and extract SetMicroStationTitle.mvba to your Workspace\Standards\vba folder. Enter keyin vba run [SetMicroStationTitle]modMain.Main to load and initialise the project.