MiRects Collection Object
MiRects MiRect |
Represents the collection of bounding rectangles in the optical character recognition (OCR) layout. A collection of MiRect objects.
Using the MiRects Collection
Use the Rects accessor property of the Word object to to return an MiRects collection. Use the Item property of the MiRects collection to return an MiRect object and gain access to the properties that describe its coordinates.
All of 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 performs optical character recognition (OCR) on the first page of a document, and then reports the bounding rectangle properties of the third recognized word.
Sub TestRects()
Dim miSelectRectDoc As MODI.Document
Dim miSelectRectWord As MODI.Word
Dim miSelectRectRects As MODI.MiRects
Dim miSelectRectRect As MODI.MiRect
Dim strRectInfo As String
' Load an existing TIFF file.
Set miSelectRectDoc = New MODI.Document
miSelectRectDoc.Create "C:\document1.tif"
' Perform OCR.
miSelectRectDoc.Images(0).OCR
' Retrieve and display bounding rectangle information.
Set miSelectRectRects = miSelectRectDoc.Images(0).Layout.Words(2).Rects
strRectInfo = "Word falls within " & miSelectRectRects.Count & _
" bounding rectangle(s)." & vbCrLf
For Each miSelectRectRect In miSelectRectRects
strRectInfo = strRectInfo & _
" Rectangle coordinates: " & vbCrLf & _
" - Left: " & miSelectRectRect.Left & vbCrLf & _
" - Right: " & miSelectRectRect.Right & vbCrLf & _
" - Top: " & miSelectRectRect.Top & vbCrLf & _
" - Bottom: " & miSelectRectRect.Bottom
Next
MsgBox strRectInfo, vbInformation + vbOKOnly, _
"Rectangle Information"
Set miSelectRectRect = Nothing
Set miSelectRectRects = Nothing
Set miSelectRectWord = Nothing
Set miSelectRectDoc = Nothing
End Sub
Properties | Count Property | Item Property
Parent Objects
Child Objects