Search
ScriptHelper.CreateFont Method
See Also
 



Creates a standard OLE Font object.

 Syntax

VB6  Copy Code

Public Function CreateFont( _
    ByVal name As String, _
    ByVal Size As CY, _
    ByVal Bold As Boolean, _
    ByVal Italic As Boolean, _
    ByVal Underline As Boolean _
) As IFontDisp

C++  Copy Code

public:
IFontDisp* CreateFont (
    BSTR name,
    CY Size,
    bool Bold,
    bool Italic,
    bool Underline
)

 Parameters

name
A string specifying the font name.
Size
The point size of the font.
Bold
The initial bold state of the font.
Italic
The initial italic state of the font.
Underline
The initial underline state of the font.

 Return Value

A font object.

 Remarks

The standard OLE Font class implementation is not marked as safe for scripting. So, depending on its security settings, Internet Explorer might display a warning message when creating an "stdfont" COM object from script, or it might refuse creating the font and return null/Nothing as the result of the VBScript CreateObject method or the JavaScript "new ActiveXObject". The CreateFont method lets you create an OLE Font object without any security restrictions.

 Example

The following code sets the text and font of a box.

VB6  Copy Code

aBox.Text = "Arial, 12, Italic"
aBox.Font = fcx.ScriptHelper.CreateFont("Arial", 12, false, true, false)

 See Also