Paul McFedries' Web Home


VBA Unleashed cover Visual Basic for Applications Unleashed

Chapter 21—Web Page Programming: ActiveX and VBScript

Go To VBA Unleashed Home Page Go To Top Go To Prev Go To Next

ActiveX: The <OBJECT> Tag

As with anything else you insert into a Web page, ActiveX controls are defined via HTML tags. In this case, the basic container tags for an ActiveX control are <OBJECT> and </OBJECT>. The <OBJECT> tag has quite a few attributes that control various aspects of the object, including the type of object, its location, the height and width, and more. Some of these attributes are listed in Table 21.1.

Table 21.1. A few attributes of the <OBJECT> tag.

AttributeDescription

ALIGN=alignment Sets the alignment of the object within the page (alignment can be LEFT, RIGHT, or CENTER).
BORDER=n If the object is a link, this attribute specifies the width of the border.
CLASSID=id A value that identifies the object implementation.
DATA=path Identifies data for the object.
HEIGHT=n The suggested height of the object.
HSPACE=n The horizontal "gutter." This is the space between the object and any text or images to the left or right of the object.
ID=ObjectName A text string that identifies the object. This value is used by programs to refer to the object.
NAME=ControlName The name of the object in a form. When the form is submitted, this value is sent along with the control's data.
STANDBY=message Sets the message that appears while the object is loading.
TYPE=type Specifies the Internet media type for data.
USEMAP=path Specifies the image map to use with the object.
VSPACE=n The vertical gutter. This is the space between the object and any text or images above or below the object.
WIDTH=n The suggested width of the object.

For registered ActiveX controls, the syntax of the CLASSID attribute is as follows:

CLSID:class-identifier

Here, class-identifier is the object's CLSID as found in the Registry. To insert an ActiveMovie control object, for example, you could use the following <OBJECT> tag:

<OBJECT
    ID="ActiveMovie1"
    WIDTH=200
    HEIGHT=100
    CLASSID="CLSID:05589FA1-C356-11CE-BF01-00AA0055595A">
Most ActiveX objects also have a selection of properties. An ActiveMovie object, for example, has a FileName property that you can use to specify a video clip file. To set an object's properties, you include one or more <PARAM> tags between the <OBJECT> and </OBJECT> tags. For each <PARAM> tag, you specify a NAME attribute and a VALUE attribute. For example, the following sequence of tags defines an ActiveMovie object and sets its FileName property to MyMovie.avi:

<OBJECT
    ID="ActiveMovie1"
    WIDTH=200
    HEIGHT=100
    CLASSID="CLSID:05589FA1-C356-11CE-BF01-00AA0055595A">
<PARAM NAME="FileName" VALUE="MyMovie.avi">
</OBJECT>

Many ActiveX controls have quite a few properties, so your <OBJECT> definitions can get quite long. Here's some code that defines a Marquee (scrolling text) object:

<OBJECT
    ID="marquee1"
    ALIGN=CENTER
    CLASSID="clsid:1a4da210-2117-11cf-be21-0080c72edd2d"
    WIDTH=200
    HEIGHT=200>
<PARAM NAME="ScrollStyleX" VALUE="Circular">
<PARAM NAME="ScrollStyleY" VALUE="Circular">
<PARAM NAME="szURL" VALUE="marqcont.htm">
<PARAM NAME="ScrollDelay" VALUE=60>
<PARAM NAME="LoopsX" VALUE=-1>
<PARAM NAME="LoopsY" VALUE=-1>
<PARAM NAME="ScrollPixelsX" VALUE=0>
<PARAM NAME="ScrollPixelsY" VALUE=-3>
<PARAM NAME="DrawImmediately" VALUE=0>
<PARAM NAME="Whitespace" VALUE=0>
<PARAM NAME="PageFlippingOn" VALUE=0>
<PARAM NAME="Zoom" VALUE=100>
<PARAM NAME="WidthOfPage" VALUE=400>
</OBJECT>

NOTE: ACTIVEX AND NAVIGATOR
ActiveX controls work fine with Internet Explorer, but what about Netscape? For starters, users won't be able to work with ActiveX controls unless they've installed the ActiveX plug-in created for Netscape by NCompass (see http://www.ncompasslabs.com/). Second, at the time this book was written, Netscape didn't support the <OBJECT> tag. Instead, you use the <EMBED SRC="Path"> tag, where Path is the pathname of the object. Netscape has promised to provide support for ActiveX in version 4 of the Navigator.

Go To VBA Unleashed Home Page Go To Top Go To Prev Go To Next


Copyright © 1995-2008 Paul McFedries and Logophilia Limited