以下代码正常工作,直到我添加一个注释,该注释会吐出我正在处理的东西的长度(第3行)。我不能为我的生活弄清楚为什么简单地添加一个消息框会崩溃整个事情。如果我向if语句添加另一个条件,也会发生同样的事情。发生什么事了?
If rs.Fields(iCols).Name = "Image1" Then
'MsgBox rs.Fields(iCols).Value
MsgBox Len(rs.Fields(iCols))
'Worksheets("Checklist").Range("A117").Value = rs.Fields(iCols).Value
Set mstream = CreateObject("ADODB.Stream")
mstream.Type = 1 ''adTypeBinary
mstream.Open
mstream.Write rs.Fields(iCols).Value
mstream.SaveToFile "C:\temp\" & "Image1" & ".jpg", 2 ''adSaveCreateOveWrite
mstream.Close
Dim myPict As Picture
Dim PictureLoc As String
PictureLoc = "C:\Temp\Image1.jpg"
With Range("A1")
'Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
Set myPict = Worksheets("PI Pics").Pictures.Insert(PictureLoc)
.RowHeight = 15
myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
myPict.Width = 200
myPict.Height = 200
End With
End If