item Method
item method as it applies to the IHTMLStyleSheetRulesCollection and FPLayoutTablesAndCells collections.
Returns an object that represents a member in one of the above collections.
expression.item(index)
*expression * Required. An expression that returns one of the above collections.
index Required Long. Specifies the ordinal position of an object in the collection.
item method as it applies to the FPHTMLFormElement, FPHTMLSelectElement, IHTMLAreasCollection, IHTMLElementCollection, IHTMLFormElement, and IHTMLSelectElement objects.
Returns an object that represents a member in one of the above objects.
expression.item(name, index)
*expression * Required. An expression that returns one of the above objects.
name Optional Variant. Specifies the name of the object.
index Optional Variant. Specifies the position of the object in the corresponding collection.
Remarks
When you use a string variable as a value to the name argument, you must use the Microsoft Visual Basic CVAR function to convert the string to a strongly typed Variant.
item method as it applies to all other objects in the Applies To list.
Returns an object that represents a member of one of the remaining objects in the Applies To list.
expression.item(pvarIndex)
*expression * Required. An expression that returns one of the above objects.
pvarIndex Required Variant. Specifies the position of the object in the corresponding collection.
Remarks
When you use a string variable as a value to the pvarIndex argument, you must use the Visual Basic CVAR function to convert the string to a strongly typed Variant.
Examples
As it applies to the IHTMLElementCollection object.
The following example function takes an FPHTMLDocument object and checks whether the images in the document have alt text assigned to them, and then returns a Boolean.
Function AllImagesHaveAltText(ByRef objDoc As FPHTMLDocument) As Boolean
Dim objImages As IHTMLElementCollection
Dim objImg As IHTMLElement
Dim intCount As Integer
Dim blnAlt As Boolean
Set objImages = objDoc.images
If objImages.Length > 0 Then
For intCount = 0 To objImages.Length - 1
Set objImg = objImages.Item(intCount)
If objImg.alt = "" Then
blnAlt = False
Exit For
Else
blnAlt = True
End If
Next
Else
blnAlt = True
End If
AllImagesHaveAltText = blnAlt
End Function
Use the following example to call the preceding function.
Sub CallAllImagesHaveAltTtext()
MsgBox AllImagesHaveAltText(objDoc:=ActiveDocument)
End Sub
As it applies to the FPHTMLFormElement object.
The following example creates a new form in the specified document and returns the FPHTMLFormElement object that represents the new form.
Function CreateNewForm(ByRef objDoc As FPHTMLDocument, _
ByRef strFormName As String) As FPHTMLFormElement
Dim objForm As IHTMLFormElement
objDoc.body.insertAdjacentHTML "beforeend", _
"<form id=""" & strFormName & """></form>"
Set objForm = objDoc.body.all.tags("form") _
.Item(CVar(strFormName))
Set CreateNewForm = objForm
End Function
Use the following example to call the preceding function.
Sub CallCreateNewForm()
Dim objForm As FPHTMLFormElement
Set objForm = CreateNewForm(objDoc:=ActiveDocument, strFormName:="newform")
objForm.insertAdjacentHTML "beforeend", "<input size=""20"">"
End Sub
Applies to | FPHTMLFiltersCollection Collection | FPHTMLFormElement Object | FPHTMLSelectElement Object | FPHTMLStyleSheetsCollection Object | FPHTMLWindow2 Object | FPHTMLWindowProxy Object | FPLayoutTablesAndCells Collection | IFPLayoutTablesAndCells Collection | IHTMLAreasCollection Collection | IHTMLElementCollection Collection | IHTMLFiltersCollection Collection | IHTMLFormElement Object | IHTMLFramesCollection2 Object | IHTMLSelectElement Object | IHTMLStyleSheetRulesCollection Collection | IHTMLStyleSheetsCollection Object | IHTMLWindow2 Object