首页 > 解决方案 > 嵌入文件不检测 excel 文件

问题描述

下面的代码被设计成可以在PowerPoint演示文稿中用他们的图像替换嵌入的文件。但是,它能够更改 visio 文件,而不是演示文稿中的 excel 文件。知道为什么会这样吗?

enter code here

  Sub imagereplacement()


    With ActivePresentation
    z = .Slides(.Slides.Count).SlideNumber
    MsgBox z, vbDefaultButton1, "Total Slides"
    End With


  For i = 1 To z
Set sld = ActivePresentation.Slides(i)
    With ActivePresentation.Slides(i)
    s = .Shapes.Count
End With

    For c = 1 To s

        If sld.Shapes(c).Type = msoEmbeddedOLEObject Then
        ActivePresentation.Slides(i).Shapes(c).Copy
        Set newsh = ActivePresentation.Slides(i).Shapes.PasteSpecial(ppPasteEnhancedMetafile)(1)
            With newsh
                .Left = ActivePresentation.Slides(i).Shapes(c).Left
                .Top = ActivePresentation.Slides(i).Shapes(c).Top

             Do
                .ZOrder (msoSendBackward)
            Loop Until .ZOrderPosition = .ZOrderPosition
            End With

            For k = ActivePresentation.Slides(i).TimeLine.MainSequence.Count To 1 Step -1
                If ActivePresentation.Slides(i).Shapes(c) Is ActivePresentation.Slides(i).TimeLine.MainSequence.Item(k).Shape Then
                ActivePresentation.Slides(i).TimeLine.MainSequence.Item(k).Shape = newsh
                End If
            Next k

        ActivePresentation.Slides(i).Shapes(c).Delete
        Else

        GoTo skip
        End If
    skip:

    Next c

   Next i
      MsgBox "Embedded files replaced by their Images", vbDefaultButton1

   End Sub

标签: excelvbaimagepowerpoint

解决方案


推荐阅读