VBA脚本将链接的图像嵌入PowerPoint。

huangapple go评论67阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年5月15日 15:33:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76251803.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定