利用 VBA 巨集,依檔名序號自動將圖片設為對應投影片背景,秒完成百頁相簿/簡報。
Sub InsertPic()
Dim i As Integer
For i = 1 To ActivePresentation.Slides.Count
ActivePresentation.Slides(i).Select
With ActiveWindow.Selection.SlideRange
.FollowMasterBackground = msoFalse
.Background.Fill.UserPicture "C:\Pictures\" & i & ".jpg"
End With
Next
End Sub
Sub InsertPicAdvanced()
Dim i As Long, picPath As String, ext As String
ext = ".jpg" ' 可改 .png .bmp
picPath = "C:\Pictures\"
For i = 1 To ActivePresentation.Slides.Count
On Error Resume Next
ActivePresentation.Slides(i).FollowMasterBackground = msoFalse
ActivePresentation.Slides(i).Background.Fill.UserPicture picPath & i & ext
On Error GoTo 0
Next
MsgBox "完成匯入 " & ActivePresentation.Slides.Count & " 張圖片"
End Sub
增加錯誤處理(缺圖不中斷)、可調路徑/副檔名、完成提示。
相簿優點:無巨集安全性問題、可批次調整亮度/對比/旋轉、自動生成標題投影片。
巨集優點:完全背景填滿、可整合既有投影片結構、可程式化控制邏輯。