Applies To | |||
Product(s): | MicroStation | ||
Version(s): | 08.11.09.xxx | ||
Environment: | Windows 7 32 bit,Windows 7 64 bit | ||
Area: | Programming | ||
Subarea: | VBA | ||
Original Author: | Bentley Technical Support | ||
Symptoms
If in VBA a new text element is generated, it is often necessary to change its properties including the font. It may happen that this change isn't made, for example, the following sequence will not be executed:
Sub TextFontNotChanged() Dim tEle As TextElement Dim oFont As Font Set tEle = CreateTextElement1(Nothing, "hello", Point3dZero, Matrix3dIdentity) Set oFont = ActiveDesignFile.Fonts("Verdana") Set tEle.TextStyle.Font = ActiveDesignFile.Fonts("Verdana") ActiveModelReference.AddElement tEle End Sub
However, when the new text font initially allocates an object of type "text font", it will work, as shown in this VBA routine:
Sub textfontchange() Dim tEle As TextElement Dim oFont As Font Set tEle = CreateTextElement1(Nothing, "hello", Point3dZero, Matrix3dIdentity) Set oFont = ActiveDesignFile.Fonts("Verdana") Set tEle.TextStyle.Font = oFont ActiveModelReference.AddElement tEle End Sub