下面的代码经过精心设计,可以在PowerPoint演示文稿中将嵌入的文件替换为它们的图像。但是,它能够更改visio文件,而不是presentaion中的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