I need to display a series of pictures, about 58 pieces, in an Image ActiveX control in Excel.
If I press a button, it should play the images one after the other like a GIF.
We cannot use gifs.
I'm a bit weak in 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
try this:
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
In my coding for such things I also use a sort of "timer" to let pictures be shown:
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