当前无法显示此图像

yydpj 2013-10-25 09:46:40
Option Explicit
Private Sub CommandButton1_Click()
Const HeaderSize As Long = 78
Const ChunkSize As Long = 100
Dim TempFile As String
Dim FileNumber As Integer
Dim sConnString As String
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim fld As ADODB.Field
Dim byteChunk() As Byte
Dim Totalsize As Long
Dim FieldSize As Long
Dim lCount As Integer

On Error GoTo ErrHandler:
sConnString = "Provider=SQLOLEDB.1;Server=80ISCALA;Database=ScalaDB;Trusted_Connection=yes;"
conn.Open sConnString
Set rst = New ADODB.Recordset
rst.Open "select * from ZZ003 where ZZ003.SC01001 ='E5001A'", conn, adOpenKeyset, adLockPessimistic
' 移至第一条记录
rst.MoveFirst
Set fld = rst.Fields("ItemPicture")
Do While Not rst.EOF
FieldSize = fld.ActualSize
lCount = lCount + 1
TempFile = "TempFile" & lCount & ".Temp"

FileNumber = FreeFile
Open TempFile For Binary Access Write As FileNumber
Totalsize = FieldSize - HeaderSize ' Substract it from the total size.
byteChunk() = fld.GetChunk(HeaderSize) ' Get rid of the header.
byteChunk() = fld.GetChunk(Totalsize)
Put FileNumber, , byteChunk()
Close FileNumber

Cells(lCount, 1).Activate
ActiveSheet.Pictures.Insert TempFile
Kill (TempFile)

rst.MoveNext
Loop
Exit Sub
ErrHandler:
MsgBox Err.Description, , "Error "

End Sub
...全文
145 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yydpj 2013-10-25
  • 打赏
  • 举报
回复
有好心人帮忙回一个么?
yydpj 2013-10-25
  • 打赏
  • 举报
回复
yydpj 2013-10-25
  • 打赏
  • 举报
回复
高手帮忙看看,以上

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧