我正在做一個動作研究的期末專案。我想創建一個可以提高學生口語能力的游戲。
我有一張帶有不同影像的 PowerPoint 幻燈片。我需要在 PowerPoint 中創建 VBA 代碼,按下按鈕或單擊物件將隨機輸出兩個影像。但是我們對 VBA 不太了解,而且到目前為止還沒有在網上找到東西。它創建一個影像,但我想知道如何讓它一次顯示兩個。
Sub RandomImage()
Randomize
RanNum% = Int(57 * Rnd) 1
Path$ = ActivePresentation.Path
FullFileName$ = Path$ "/" CStr(RanNum%) ".png"
ActivePresentation.Slides(1).Shapes.AddPicture(FileName:=FullFileName$, LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=100, Top:=100, Width:=500).Select
End Sub
uj5u.com熱心網友回復:
您可以使用for-loop。
您將不得不考慮 left-Parameter 的邏輯,以便兩張圖片彼此相鄰 - 請在代碼中查看我的建議
Sub RandomImage()
Dim i As Long
Dim posLeft As Long
For i = 1 To 2
Randomize
RanNum% = Int(57 * Rnd) 1
Path$ = ActivePresentation.Path
FullFileName$ = Path$ "/" CStr(RanNum%) ".png"
posLeft = 100 ((i-1) * 510) '-->>> you will have to adjust this to your needs
ActivePresentation.Slides(1).Shapes.AddPicture(FileName:=FullFileName$, LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, _
Left:=posLeft, Top:=100, Width:=500).Select
Next
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/470575.html
上一篇:有沒有辦法匹配UITableViewDiffableDataSource中的節數匹配字典鍵計數
下一篇:VBAByRef如何在幕后作業?
