Add Tools-->Reference-->Microsoft Office Document Imaging Viewer Control 12
MODI
Create an image as a test and store in c drive "C:\canvas.png"
Then run this code in a new button
Sub Button1_Click()
Dim modiDoc As MODI.Document
Dim modiLayout As MODI.Layout
Dim strLayoutInfo As String
Set modiDoc = New MODI.Document
modiDoc.Create "C:\canvas.png"
modiDoc.Images(0).OCR
Set modiLayout = modiDoc.Images(0).Layout
strLayoutInfo = _
"Language: " & modiLayout.Language & vbCrLf & _
"Number of characters: " & modiLayout.NumChars & vbCrLf & _
"Number of fonts: " & modiLayout.NumFonts & vbCrLf & _
"Number of words: " & modiLayout.NumWords & vbCrLf & _
"Beginning of text: " & Left(modiLayout.Text, 50) & vbCrLf & _
"First word of text: " & modiLayout.Words(0).Text
MsgBox strLayoutInfo, vbInformation + vbOKOnly, _
"Layout Information"
Set modiLayout = Nothing
Set modiDoc = Nothing
End Sub
MODI
Create an image as a test and store in c drive "C:\canvas.png"
Then run this code in a new button
Sub Button1_Click()
Dim modiDoc As MODI.Document
Dim modiLayout As MODI.Layout
Dim strLayoutInfo As String
Set modiDoc = New MODI.Document
modiDoc.Create "C:\canvas.png"
modiDoc.Images(0).OCR
Set modiLayout = modiDoc.Images(0).Layout
strLayoutInfo = _
"Language: " & modiLayout.Language & vbCrLf & _
"Number of characters: " & modiLayout.NumChars & vbCrLf & _
"Number of fonts: " & modiLayout.NumFonts & vbCrLf & _
"Number of words: " & modiLayout.NumWords & vbCrLf & _
"Beginning of text: " & Left(modiLayout.Text, 50) & vbCrLf & _
"First word of text: " & modiLayout.Words(0).Text
MsgBox strLayoutInfo, vbInformation + vbOKOnly, _
"Layout Information"
Set modiLayout = Nothing
Set modiDoc = Nothing
End Sub
0 comentarios:
Publicar un comentario