To be most productive in MicroStation VBA consider learning a couple keystrokes to help make your learning MicroStation VBA easier.
- Open the Microsoft VBA Editor (Alt + F11)
- Open the Microsoft VBA Object Browser (F2)
- Search in the Object Browser for keywords of interest
- Open help for a specific item (Select an item, then press F1)
- Search the open help file (Click the Search Tab, then use wildcard and boolean search operators. e.g. *linear* AND *element* AND *properties*
- TIP: Always look to the top of each VBA help page for an "Example" link providing code snips to quickly test functionality.
VBA programs process selected elements using a Model Reference (like separate sheets in a book), so code to process selected elements in the ActiveModelReference would look somewhat like this:
Option Explicit Sub ProcessSelectedElements() Dim oModel As ModelReference: Set oModel = ActiveModelReference Dim oEE As ElementEnumerator: Set oEE = oModel.GetSelectedElements() Dim oEl As Element Dim sMessage As String Do While oEE.MoveNext If sMessage <> "" Then sMessage = sMessage & ", " & DLongToString(oEE.Current.ID) Else sMessage = DLongToString(oEE.Current.ID) End If Loop MsgBox sMessage, vbOKOnly, "Selected Element IDs" End Sub