英文:
VBA script to embedded linked image in PowerPoint
问题
I am looking for a solution to save a PowerPoint presentation as pptx with all linked images in embedded format in order to share the presentation without the linked images. I need this as I am updating periodically the same template presentation with updated images.
First I created the template pptx using "Link to file". that way, the pptx is updated when image sources change. But I cannot find a way to export in pptx with embedded images. pdf works but this does not fit my purpose.
If I use "Insert and Link", the image selected the first time is used if the link is missing.
I tried all potential pptx or related format to "save as" without success. But I am happy to learn if simple solution like this would work.
alternatively, I think a VBA script looping on all slides and all images, and changing the linked images to an embedded images, will be a good solution. Any idea how to solve this?
Thanks
英文:
I am looking for a solution to save a PowerPoint presentation as pptx with all linked images in embedded format in order to share the presentation without the linked images. I need this as I am updating periodically the same template presentation with updated images.
First I created the template pptx using "Link to file". that way, the pptx is updated when image sources change. But I cannot find a way to export in pptx with embedded images. pdf works but this does not fit my purpose.
If I use "Insert and Link", the image selected the first time is used if the link is missing.
I tried all potential pptx or related format to "save as" without success. But I am happy to learn if simple solution like this would work.
alternatively, I think a VBA script looping on all slides and all images, and changing the linked images to an embedded images, will be a good solution. Any idea how to solve this?
Thanks
答案1
得分: 3
Sub EmbedImages()
Dim slide As Slide
Dim shape As Shape
' 遍历演示文稿中的每一张幻灯片
For Each slide In ActivePresentation.Slides
' 遍历幻灯片中的每一个形状
For Each shape In slide.Shapes
If shape.Type = msoLinkedPicture Then
shape.LinkFormat.BreakLink ' 断开与原始图像的链接
shape.LinkFormat.SavePictureWithDocument = True ' 设置形状保存图片与文档一起
End If
Next shape
Next slide
End Sub
英文:
try this:
Sub EmbedImages()
Dim slide As Slide
Dim shape As Shape
' Loop through each slide in the presentation
For Each slide In ActivePresentation.Slides
' Loop through each shape in the slide
For Each shape In slide.Shapes
If shape.Type = msoLinkedPicture Then
shape.LinkFormat.BreakLink ' Break the link to the original image
shape.LinkFormat.SavePictureWithDocument = True ' Set the shape to save the picture with the document
End If
Next shape
Next slide
End Sub
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论