How do you get the Font Name of an Enter Data Field?

I have a design file with 1 Enter Data field element.

How do you get the Font Name from this text string?

Thanks!

Regan

  • Unknown said:

    I have a design file with 1 Enter Data field element. How do you get the Font Name from this text string?

    An enter-data field is part of a TextElement.  A TextElement has only one font: you can't have multiple fonts in a TextElement.  The answer to your question is: Get the font of the TextElement that stores the enter-data field.

    However, there's no straightforward way to get the font of a TextElement.  You have to get its TextStyle, then obtain the font from the TextStyle...

    Sub GetFont (ByVal oText As TextElement)
      Dim oStyle As TextStyle
      Set oStyle = oText.TextStyle
      If Not oStyle Is Nothing Then
        Dim oFont As Font
        Set oFont = oStyle.Font
        If oFont Is Nothing Then
           Debug.Print "Text style '" & oStyle.Name & "' has no font"
        Else
           Debug.Print "Text style  '" & oStyle.Name & "' uses font '" & oFont.Name & "'"
        End If
      End If
    End Sub

     
    Regards, Jon Summers
    LA Solutions

  • I'm using MicroStation 08.11.09.357 and using vba.

    I figured out the problem - the font actually was invalid. If I changed the font of the enter data field, the error went away.
    Thanks,
    Regan
  • Please follow the MicroStation Programming forum best practices.

    Identify Your Platform

    Please identify the version of MicroStation, or other product such as PowerDraft, that you are using: MicroStation CONNECT or MicroStation V8i.

    The APIs supplied with MicroStation CONNECT are different to those supplied with MicroStation V8i. Consequently, our answers are likely to be different.

    Identify Your Programming Language

    Are you writing MDL, C++, C#, VB.NET or MicroStation VBA?

    Are you building an in-process app. (i.e. a DLL) or a stand-alone app. (i.e. an EXE)?

    Code Syntax Highlighting

    When you post code, use the Forum advanced editor's syntax highlighting tool. That's the icon that resembles a pencil:  Syntax Highlighter

     
    Regards, Jon Summers
    LA Solutions