I am having an issue releasing a file opened using the MODI library. Here is the code (docTif is the MiDocView object on my form):
Dim tmpTif As String
Dim tmpDoc As Document
Dim tmpImg as MODI.Image
...
(a TIF is created and saved to disk. the name of the file is stored in tmpTif)
...
Set tmpDoc = New Document
tmpDoc.Create tmpTif
docTif.Document = tmpDoc
Set tmpDoc = Nothing
...
(at this point, the tif is loaded to the document viewer. later in the code, I want to release the TIF and remove it)
...
Set tmpDoc = docTif.Document
Set tmpImg = tmpDoc.Images(0)
tmpDoc.Images.Remove tmpImg
Set tmpDoc = Nothing
Set tmpImg = Nothing
If Dir(tmpTif) <> "" Then Kill tmpTif
The code keeps abending on the 'Kill' statement with a permission denied. If I try to open the TIF while in this routine with Microsoft Office Document Imaging, it also tells me the file is in use. However, after the form is unloaded, the file is accessible. The problem is that I cannot clean up the temporary TIF file because I cannot 'Kill' it before the form unloads.
By the way, 'Set docTif = Nothing" gives an 'object required' error. 'docTif = Nothing" isn't supported.
Any ideas?
Dim tmpTif As String
Dim tmpDoc As Document
Dim tmpImg as MODI.Image
...
(a TIF is created and saved to disk. the name of the file is stored in tmpTif)
...
Set tmpDoc = New Document
tmpDoc.Create tmpTif
docTif.Document = tmpDoc
Set tmpDoc = Nothing
...
(at this point, the tif is loaded to the document viewer. later in the code, I want to release the TIF and remove it)
...
Set tmpDoc = docTif.Document
Set tmpImg = tmpDoc.Images(0)
tmpDoc.Images.Remove tmpImg
Set tmpDoc = Nothing
Set tmpImg = Nothing
If Dir(tmpTif) <> "" Then Kill tmpTif
The code keeps abending on the 'Kill' statement with a permission denied. If I try to open the TIF while in this routine with Microsoft Office Document Imaging, it also tells me the file is in use. However, after the form is unloaded, the file is accessible. The problem is that I cannot clean up the temporary TIF file because I cannot 'Kill' it before the form unloads.
By the way, 'Set docTif = Nothing" gives an 'object required' error. 'docTif = Nothing" isn't supported.
Any ideas?