IHTMLSelectionObject Object

Microsoft FrontPage Visual Basic

IHTMLSelectionObject Object

Multiple objects IHTMLSelectionObject

Represents the text selected in the page window in Microsoft FrontPage.

Using the IHTMLSelectionObject Object

Use the selection property of the FPHTMLDocument or IHTMLDocument2 object to return an IHTMLSelectionObject object. The following example accesses the selection in the active document.

    Dim objSelection As IHTMLSelectionObject

Set objSelection = ActiveDocument.Selection
  

The IHTMLSelectionObject object contains methods, such as the clear method, that allows you to clear the contents of the selection if the type property for the selection returns "text". The following example clears the contents of the current selection.

    If ActiveDocument.Selection.Type = "Text" Then _
    ActiveDocument.Selection.Clear
  

Use the empty method to clear the contents of a selection if the type property returns something other than "text".

    If ActiveDocument.Selection.Type <> "Text" Then _
    ActiveDocument.Selection.empty
  

Use the createRange method to create an IHTMLTxtRange object to access additional properties and method that you can perform on the selected text.

    Dim objRange As IHTMLTxtRange

Set objRange = ActiveDocument.Selection.createRange