有人可以就此启发我。我需要使用按钮在Excel的Image Activex控件中显示一系列图片(如约58件)。如果按下按钮,它会像GIF一样自动播放1张图像(顺便说一下,我们不能使用GIF)。我在LOOPS中有点弱,所以有人可以帮我
Sub Button3_Click()
Dim x As Integer
x = 1
ActiveSheet.Image1.Picture = LoadPicture(ThisWorkbook.Path & "\Images\Irene\" & x & ".jpg")
'MsgBox (ThisWorkbook.Path & "\Images\Irene\" & x & ".jpg")
End Sub
答案 0 :(得分:0)
试试这个:
Sub main()
Dim iPic As Long
With ActiveSheet.Image1
For iPic = 1 To 6
.Picture = LoadPicture(ThisWorkbook.Path & "\Images\Irene\" & iPic & ".jpg")
Next
End With
End Sub
在我对这些事情的编码中,我也使用了一种"计时器"让图片显示:
Sub main()
Dim iPic As Long
With ActiveSheet.Image1
For iPic = 1 To 6
.Picture = LoadPicture(ThisWorkbook.Path & "\Images\Irene\" & iPic & ".jpg")
MyWait '<--| added to let pictures be actually shown one by one
Next
End With
End Sub
Sub MyWait()
Dim time1, time2
time1 = Now
time2 = Now + TimeValue("0:00:01")
Do Until time1 >= time2
DoEvents
time1 = Now()
Loop
End Sub