在 Excel 中的图像 ActiveX 中显示一堆图像

Display A Bunch of Images in a Image ActiveX in Excel

有人可以启发我吗?我需要使用按钮在 Excel 的 Image Activex 控件中显示一系列图片(大约 58 张)。如果我按下一个按钮,它会自动像 GIF 一样逐一播放图像(顺便说一句,我们不能使用 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

试试这个:

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

在我编写此类代码时,我还使用了一种 "timer" 来显示图片:

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