jdmartin74
Programmer
I have a database with a table of images stored as OLE Object field types.
I would like to export these to individual files, however, I can't seem to do it. I have tried the following code below. It works in that the file is written, however, it is not a usable bitmap file.
Can anyone help? Thanks very much.
Function WriteFile()
Dim iFileNum As Integer, strFile As String, strOutput As String
Dim strImage As String
Dim db As Database, rs As Recordset, strSQL As String
strFile = "d:\test.bmp"
Set db = CurrentDb()
strSQL = "select ImageData from tblImages where ImageID = 800"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
With rs
Do Until .EOF
strOutput = !ImageData.GetChunk(0, !ImageData.FieldSize)
' Open the log file and write the entry
iFileNum = FreeFile()
Open strFile For Append Access Write Lock Read Write As #iFileNum
Print #iFileNum, strOutput
Close #iFileNum
.MoveNext
Loop
End With
End Function
I would like to export these to individual files, however, I can't seem to do it. I have tried the following code below. It works in that the file is written, however, it is not a usable bitmap file.
Can anyone help? Thanks very much.
Function WriteFile()
Dim iFileNum As Integer, strFile As String, strOutput As String
Dim strImage As String
Dim db As Database, rs As Recordset, strSQL As String
strFile = "d:\test.bmp"
Set db = CurrentDb()
strSQL = "select ImageData from tblImages where ImageID = 800"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
With rs
Do Until .EOF
strOutput = !ImageData.GetChunk(0, !ImageData.FieldSize)
' Open the log file and write the entry
iFileNum = FreeFile()
Open strFile For Append Access Write Lock Read Write As #iFileNum
Print #iFileNum, strOutput
Close #iFileNum
.MoveNext
Loop
End With
End Function