読者です 読者をやめる 読者になる 読者になる

CGメソッド

CG制作に関してのヒント

MENU

【PowerPoint】画像の置換マクロ

PowerPoint

follow us in feedly

パワポの画像の置換マクロを調べてみたものの、あまり良い方法が見つからず。

出来なくはないので、一応メモ。

画像置換のマクロ

Sub 画像置換()

Dim Pres As Presentation
Dim Sld As Slide
Dim shp As Shape
Dim l As Single
Dim t As Single
Dim h As Single
Dim w As Single
Dim strName As String

'画像のパス
Dim A As Variant
A = Array("C:\Users\namae\Desktop\01.png", "C:\Users\namae\Desktop\02.png", "C:\Users\namae\Desktop\03.png")
Dim idx As Integer


For Each Sld In ActivePresentation.Slides
For Each shp In Sld.Shapes
If shp.Type = msoPicture Then
l = shp.Left
t = shp.Top
h = shp.Height
w = shp.Width
strName = shp.Name
shp.Delete
Set shp = Sld.Shapes.AddPicture(A(idx), msoFalse, msoCTrue, l, t, w, h)
idx = idx + 1
If idx > UBound(A) Then idx = 0
shp.Name = strName
End If
Next shp
Next Sld
End Sub

参考

Replacing (changing) the pictures in PowerPoint presentation