Automate office document imaging 2003

J

Jean-Marc Boedt

hi,

I automate office document imaging in a vb.net application
in order to obtain the ocr's result on a given tiff file.
Everything is ok except that after my subroutine I got a
lock on my tiff file and I can't move or delete the file.

thanks for your help
this is the code I use :

Private Sub scannerFichierTIF(ByVal fichierTiff As String)
Dim doc As MODI.Document
Dim img As MODI.Image
Dim buffer As StreamWriter

'Création du fichier qui recevra le texte
résultant de l'OCR
buffer = File.CreateText("resultatocr.txt")

doc = CType(CreateObject("MODI.Document"),
MODI.Document)
doc.Create(fichierTiff)
doc.OCR(MODI.MiLANGUAGES.miLANG_FRENCH, True, True)
For i As Integer = 0 To doc.Images.Count - 1
img = CType(doc.Images.Item(i), MODI.Image)
Buffer.WriteLine(img.Layout.Text())
Next

'Fermeture des différents fichiers
buffer.Flush()
buffer.Close()
doc.Save()
doc.Close()
doc = Nothing
End Sub
 
K

Kevin McBride

I saw your post and it appears that you are using .NET.
It's entirely possible that the object still is active
and is not closing, due to late garbage collection. I've
run into the same problem. I ended up having to force a
close on the Word.Application, which you can do using
Dispose or with something like:



Public Function KillProcess(ByVal ProcessName As
String)



Try

Dim procLocalSystem() As Process

Dim procKill As Process

procLocalSystem = Process.GetProcessesByName
(ProcessName)

For Each procKill In procLocalSystem

procKill.CloseMainWindow()



If Not procKill.WaitForExit(1000) Then

procKill.Kill()

End If

Next



Catch ex As Exception

End Try

End Function



This is kind of a sledgehammer method, but dammit, it
works!



I also noticed that you are using some kind
of 'MODI.APPLICATION'. That's not Word, is it? Are you
generating a Tiff file, out of a Word document, or a Word
document out of Tiff, or does Word not have any bearing
on this whatsoever?
 
A

Andy Rice

Jean-Marc Boedt said:
hi,

I automate office document imaging in a vb.net application
in order to obtain the ocr's result on a given tiff file.
Everything is ok except that after my subroutine I got a
lock on my tiff file and I can't move or delete the file.

thanks for your help
this is the code I use :

Private Sub scannerFichierTIF(ByVal fichierTiff As String)
Dim doc As MODI.Document
Dim img As MODI.Image
Dim buffer As StreamWriter

'Cr ation du fichier qui recevra le texte
r sultant de l'OCR
buffer = File.CreateText("resultatocr.txt")

doc = CType(CreateObject("MODI.Document"),
MODI.Document)
doc.Create(fichierTiff)
doc.OCR(MODI.MiLANGUAGES.miLANG FRENCH, True, True)
For i As Integer = 0 To doc.Images.Count - 1
img = CType(doc.Images.Item(i), MODI.Image)
Buffer.WriteLine(img.Layout.Text())
Next

'Fermeture des diff rents fichiers
buffer.Flush()
buffer.Close()
doc.Save()
doc.Close()
doc = Nothing
End Sub

I am trying to automate Document Imaging 2003, in Visual FoxPro.
Do you know where can I find the Automation documentation?

( I understand French, so I so what you're doing.
But "mon Dieu", I need some documentation! )

Thank you,
Andy Rice
San Diego, CA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top