I like to change Text style, height, width and level, properties by recorded macro or mvba. for selected text / contents in model ( not in tittle block )

kindly assist to give a program.



  • What version of MicroStation are you using?

    Have you looked at the examples in the MVBA Help?

    If you can figure out how get your selection of text to change, you should be able to enumerate them and go through each one, changing the properties you want, then rewriting and redrawing each element. It gets a little more complicated if the elements are text nodes, because those are made up of more than one text element; you will have to step through those to change each text element in a text node, but it's not that difficult. If you want text in notes or dimensions, that's a whole different concept, and you may not be able to do what you want with them.


    Power GeoPak
    Power InRoads
    OpenRoads Designer 2021 R2


  • Here is a simple example of how to do it. The ChangeSelectedText sub is the macro entry point. It grabs the selected elements and passes any text elements to the ModifyTextProperties sub. In this example the text is changed to level Default with a height and width of 10.

    Option Explicit
    Public Sub ChangeSelectedText()
        If ActiveModelReference.AnyElementsSelected Then
            Dim elArray() As Element
            Dim i As Long
            Dim txtLevel As Level
            Set txtLevel = ActiveDesignFile.Levels.Find("Default")
            elArray = ActiveModelReference.GetSelectedElements.BuildArrayFromContents
            For i = LBound(elArray) To UBound(elArray)
                If elArray(i).Type = msdElementTypeText Then
                    ModifyTextProperties elArray(i), txtLevel, 10, 10
                End If
            ShowError "No elements selected"
            Exit Sub
        End If
    End Sub
    Private Sub ModifyTextProperties(elText As TextElement, txtLevel As Level, txtHeight As Double, txtWidth As Double)
        With elText
            Set .Level = txtLevel
            .TextStyle.Height = txtHeight
            .TextStyle.Width = txtWidth
        End With
    End Sub

    Rod Wing
    Senior Systems Analyst