Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

microsoft office document image library

Status
Not open for further replies.

dejfatman

Programmer
Jan 24, 2002
34
0
0
US
Hi,

I'm writing an app that strips .tif images from a file that contains a concatination of tifs, and then displays them, but I'm running into some problems regarding access errors. Here's the code that strips the .tif and displays it:

Dim arImage() As Byte
Dim ff As Integer

ff = FreeFile
ReDim arImage(imgSize)
Open fimFile For Binary As #ff
Get #ff, imgPoint, arImage
Close #ff
ff = FreeFile
Open "tmp.tif" For Binary As #ff
Put #ff, , arImage
Close #ff
tifIDX.FileName = "tmp.tif"

imgPoint - long, pointer in fimFile of start of .tif
imgSize - long, size in bytes of .tif
tifIDX - MiDocView (Microsoft Office Document Viewer)

The first time I call the routine, it displays the stripped .tif in my MiDocView (tifIDX). But any subsequent call after that gives me a file/path access error at "put #ff, , arImage". I don't get it because I've closed the files each time through, and I've checked the MiDocView.Filename at the start of the routine, and it is always = "" to start, so I don't think the MiDocView is still holding the file.

This code will only work once, and then I actually have to close the project to run it again.

Any ideas?
 
I have had similar problems with this. I don't have the code in front of me but I think there is something that needs to be set = nothing in order for this to work properly. I think there was a document property or something similar.
 
Thanks,

I figured it out based on what you said. This code works:

Dim arImage() As Byte
Dim ff As Integer
Dim myTifDoc As Document

ff = FreeFile
ReDim arImage(imgSize)
Open fimFile For Binary As #ff
Get #ff, imgPoint, arImage
Close #ff
ff = FreeFile
Open "tmp.tif" For Binary As #ff
Put #ff, , arImage
Close #ff
Set myTifDoc = New Document
myTifDoc.Create "tmp.tif"
myTiff.Document = myTifDoc
Set myTifDoc = Nothing


Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top