Accessから画像を抜き出してファイルとして保存
Option Compare Database
ここで使用する
DisplayBitmap関数 は、MSDN2001/10月版にも収録されています。
Private Sub GetImageFromTabele()
Dim ary1() As Byte
Dim strtabel As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
strtable = "Employees"
rs.Open "select * from " & strtable, cnn, adOpenStatic, adLockOptimistic
Debug.Print rs.RecordCount
Do Until rs.EOF = True
ary1 = DisplayBitmap(rs.Fields("Photo"))
'BITMAP ファイルへの保管
Open Left(CurrentDb.Properties(0), InStrRev(CurrentDb.Properties(0), "\") - 1) & "\" & rs.Fields(0).Value & " .jpg" For Binary As #1
Put #1, , ary1()
Close #1
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set cnn = Nothing
MsgBox "終了"
End Sub
|
© 2004 I Love Balard. All Rights Reserved.
|