[CONNECT VBA] Applying a Text Style from a dgnlib to an element during scan

I feel like I have done this before but can't get it to work for some reason.

I would like to scan a model for text elements and set the text style for each one found.

I have the scan etc working fine but can't apply the text style -

        'Change text style of sign names
        
        Do While oEnumerator.MoveNext
             
            Set oText = oEnumerator.Current

            Set oText.TextStyle = oFile.TextStyles("1.8mm BG")
                
            'oEnumerator.Current.Rewrite
            
            oText.Redraw msdDrawingModeNormal
            oText.Rewrite
            
            counter = counter + 1
         
        Loop

Any help would be appreciated.

Parents
  • I have the scan etc working fine but can't apply the text style

    Text styles in VBA seem often to cause problems.  Try something like this...

    Dim oStyle As TextStyle
    Set oStyle = oFile.TextStyles("1.8mm BG")
    Debug.Assert Not oStyle Is Nothing
    Do While oEnumerator.MoveNext
      Set oText = oEnumerator.Current.AsTextElement
      Debug.Assert Not oText Is Nothing
      Set oText.TextStyle = oStyle
      oText.Rewrite
      counter = counter + 1
    Loop
    

     
    Regards, Jon Summers
    LA Solutions

Reply
  • I have the scan etc working fine but can't apply the text style

    Text styles in VBA seem often to cause problems.  Try something like this...

    Dim oStyle As TextStyle
    Set oStyle = oFile.TextStyles("1.8mm BG")
    Debug.Assert Not oStyle Is Nothing
    Do While oEnumerator.MoveNext
      Set oText = oEnumerator.Current.AsTextElement
      Debug.Assert Not oText Is Nothing
      Set oText.TextStyle = oStyle
      oText.Rewrite
      counter = counter + 1
    Loop
    

     
    Regards, Jon Summers
    LA Solutions

Children