Share via


FPHTMLWebPartElement Object

FPHTMLWebPartElement
Multiple objects

Represents a Web part in an HTML document. See also the IHTMLWebPartElement object.

This object is supported only by Web pages or sites that are based on Microsoft Windows SharePoint Services.

Using the FPHTMLWebPartElement Object

Use the webParts property of the FPHTMLDocument object to return an IHTMLElementCollection collection that represents a collection of all the Web Parts within a document. Use the Item method to return an FPHTMLWebPartElement object that accesses a specific Web Part, referenced by ordinal number. The following example accesses the first Web Part in the active document.

Dim objPart As FPHTMLWebPartElement

Set objPart = ActiveDocument.webParts.Item(0)

Use the InsertAdjacentHTML method, as shown in the following example, to insert a Web Part into a document.

Public Sub InsertWebPart()

    Dim strPageDirective As String
    Dim strRegisterDirective As String
    Dim strWebPart As String
    Dim objWebPart As FPHTMLWebPartElement

    strPageDirective = "<%@ Page Language=""C#"" Debug=""true""%>"

    strRegisterDirective = "<%@ Register TagPrefix=""WebPartPages"" " & _
        "Namespace=""Microsoft.SharePoint.WebPartPages"" " & _
        "Assembly=""Microsoft.SharePoint, Version=11.0.0.0, " & _
        "Culture=neutral, PublicKeyToken=71e9bce111e9429c""%>"

    ActiveDocument.DocumentHTML = strPageDirective & vbCrLf & _
        strRegisterDirective & vbCrLf & ActiveDocument.DocumentHTML

    strWebPart = "<form runat=""server"">" & vbCrLf & _
        "<WebPartPages:ImageWebPart webpart=""true"" " & _
        "runat=""server"" id=""insertedwebpart"">" & vbCrLf & _
        "</WebPartPages:ImageWebPart>" & vbCrLf & "</form>"

    ActiveDocument.body.insertAdjacentHTML "afterBegin", strWebPart
    Set objWebPart = ActiveDocument.webParts.Item("insertedwebpart")

End Sub

Properties | all Property | assembly Property | children Property | className Property | Document Property | filters Property | id Property | innerHTML Property | innerText Property | isTextEdit Property | lang Property | language Property | namespace Property | offsetHeight Property | offsetLeft Property | offsetParent Property | offsetTop Property | offsetWidth Property | onafterupdate Property | onbeforeupdate Property | onclick Property | ondataavailable Property | ondatasetchanged Property | ondatasetcomplete Property | ondblclick Property | ondragstart Property | onerrorupdate Property | onfilterchange Property | onhelp Property | onkeydown Property | onkeypress Property | onkeyup Property | onmousedown Property | onmousemove Property | onmouseout Property | onmouseover Property | onmouseup Property | onrowenter Property | onrowexit Property | onselectstart Property | outerHTML Property | outerText Property | parentElement Property | parentTextEdit Property | recordNumber Property | sourceIndex Property | style Property | tagName Property | title Property

Methods | click Method | contains Method | getAttribute Method | getPartProperty Method | insertAdjacentHTML Method | insertAdjacentText Method | removeAttribute Method | removePartProperty Method | scrollIntoView Method | setAttribute Method | setPartProperty Method | toString Method

Events | onafterupdate Event | onbeforeupdate Property | onclick Event | ondataavailable Event | ondatasetchanged Event | ondatasetcomplete Event | ondblclick Event | ondragstart Event | onerrorupdate Event | onfilterchange Event | onhelp Event | onkeydown Property | onkeypress Event | onkeyup Event | onmousedown Event | onmousemove Event | onmouseout Event | onmouseover Event | onmouseup Event | onrowenter Event | onrowexit Event | onselectstart Event

Parent Objects

Child Objects | IHTMLElement Object | IHTMLFiltersCollection Object | IHTMLStyle Object