TEXT

Hi,

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.

Regards,

Harikrishnan.R

Parents
  • 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
            Next
        Else
            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
            .Rewrite
        End With
    End Sub
    

    Rod Wing
    Senior Systems Analyst

Reply
  • 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
            Next
        Else
            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
            .Rewrite
        End With
    End Sub
    

    Rod Wing
    Senior Systems Analyst

Children
No Data