Powerpoint VBA 在主题更改后更改布局上的图片
Powerpoint VBA change picture on layout after theme change
我有一个 Powerpoint 模板,标题幻灯片布局上的图片。用户可以打开自定义用户窗体来更改图片(VBA 删除旧图片,然后插入 pic-of-choice)。
但用户更改主题后,后续图片更改不可见。据我所知,这是因为图片仅在原始主题的标题幻灯片布局中发生了变化。更改主题实际上添加了一个新的幻灯片母版。
有没有办法更改我演示文稿中每张幻灯片母版的标题幻灯片布局上的图片?
这是 VBA 代码:
Set shp = ActivePresentation.SlideMaster.CustomLayouts(1).Shapes(strShapeName)
With shp
sngTop = .Top
sngLeft = .Left
sngWidth = .Width
sngHeight = .Height
.Delete
End With
Set shp = ActivePresentation.SlideMaster.CustomLayouts(1).Shapes.AddPicture _
(strFullFileName, msoFalse, msoTrue, _
sngLeft, sngTop, sngWidth, sngHeight)
With shp
.ZOrder msoSendToBack
.Name = strShapeName
End With
感谢任何建议。
尝试这样的事情:
Dim oDes As Design
Dim shp As Shape
For Each oDes In ActivePresentation.Designs
Set shp = oDes.SlideMaster.CustomLayouts(1).Shapes(strShapeName)
With shp
sngTop = .Top
sngLeft = .Left
sngWidth = .Width
sngHeight = .Height
.Delete
End With
Set shp = oDes.SlideMaster.CustomLayouts(1).Shapes.AddPicture _
(strFullFileName, msoFalse, msoTrue, _
sngLeft, sngTop, sngWidth, sngHeight)
With shp
.ZOrder msoSendToBack
.Name = strShapeName
End With
Next ' Design
我有一个 Powerpoint 模板,标题幻灯片布局上的图片。用户可以打开自定义用户窗体来更改图片(VBA 删除旧图片,然后插入 pic-of-choice)。
但用户更改主题后,后续图片更改不可见。据我所知,这是因为图片仅在原始主题的标题幻灯片布局中发生了变化。更改主题实际上添加了一个新的幻灯片母版。
有没有办法更改我演示文稿中每张幻灯片母版的标题幻灯片布局上的图片?
这是 VBA 代码:
Set shp = ActivePresentation.SlideMaster.CustomLayouts(1).Shapes(strShapeName)
With shp
sngTop = .Top
sngLeft = .Left
sngWidth = .Width
sngHeight = .Height
.Delete
End With
Set shp = ActivePresentation.SlideMaster.CustomLayouts(1).Shapes.AddPicture _
(strFullFileName, msoFalse, msoTrue, _
sngLeft, sngTop, sngWidth, sngHeight)
With shp
.ZOrder msoSendToBack
.Name = strShapeName
End With
感谢任何建议。
尝试这样的事情:
Dim oDes As Design
Dim shp As Shape
For Each oDes In ActivePresentation.Designs
Set shp = oDes.SlideMaster.CustomLayouts(1).Shapes(strShapeName)
With shp
sngTop = .Top
sngLeft = .Left
sngWidth = .Width
sngHeight = .Height
.Delete
End With
Set shp = oDes.SlideMaster.CustomLayouts(1).Shapes.AddPicture _
(strFullFileName, msoFalse, msoTrue, _
sngLeft, sngTop, sngWidth, sngHeight)
With shp
.ZOrder msoSendToBack
.Name = strShapeName
End With
Next ' Design