GetSelectRects Method
Returns the collection of bounding rectangles in the user's text selection in the viewer control. Returns an MiSelectRects collection.
expression.GetSelectRects
*expression * Required. An expression that returns an IMiSelectableItem object.
Remarks
You can retrieve the user's selection in the viewer control as text using the viewer's TextSelection property, which returns an IMiSelectableItem object. Use the GetSelectRects method of the IMiSelectableItem object to return an MiSelectRects collection of the bounding rectangles in the user's text selection in the viewer control. Each MiSelectRect object exposes its coordinates (Top, Left, Bottom, and Right properties) as well as the page number (PageNumber property) on which it appears.
All the rectangle objects and properties in the Microsoft Office Document Imaging 2003 object model work as follows:
- the Top and Bottom properties represent the distance in pixels from the top edge of the containing image.
- the Left and Right properties represent the distance in pixels from the left edge of the containing image.
Example
The following example reports the page number and the coordinates of each bounding rectangle in the user's text selection in the viewer control.
Sub TestGetSelectRects()
Dim miTextSel As MODI.IMiSelectableItem
Dim miSelectRects As MODI.miSelectRects
Dim miSelectRect As MODI.miSelectRect
Dim strTextSelInfo As String
Set miTextSel = MiDocView1.TextSelection
Set miSelectRects = miTextSel.GetSelectRects
strTextSelInfo = _
"Bounding rectangle page & coordinates: " & vbCrLf
For Each miSelectRect In miSelectRects
With miSelectRect
strTextSelInfo = strTextSelInfo & _
.PageNumber & ", " & .Top & ", " & _
.Left & ", " & .Bottom & ", " & _
.Right & vbCrLf
End With
Next
MsgBox strTextSelInfo, vbInformation + vbOKOnly, _
"Text Selection Info"
Set miSelectRect = Nothing
Set miSelectRects = Nothing
Set miTextSel = Nothing
End Sub
Applies to | IMiSelectableItem Object