Saya memiliki beberapa kode yang dapat Anda gunakan untuk PPT 2003, karena tampaknya tidak memiliki mekanisme untuk mengubah gambar tanpa mengacaukan animasi. Anda harus mengetahui cara memilih gambar mana yang akan digunakan (saya akan menggunakan ActiveWindow.Selection.ShapeRange (1)):
Function UpdateImage_BuildNewFromFile(TheImage As PowerPoint.Shape, ImageFile As String) As Boolean
' Create a new shape and add the image (unlinked) from TheImage, copy attributes and size, position, etc...
UpdateImage_BuildNewFromFile = True
On Error Resume Next
'On Error GoTo PROC_ERR
If TheImage Is Nothing Then GoTo PROC_ERR_BELOW
If ImageFile = "" Then GoTo PROC_ERR_BELOW
If Not TypeOf TheImage.Parent Is Slide Then GoTo PROC_ERR_BELOW
Dim TheSlide As PowerPoint.Slide
Set TheSlide = TheImage.Parent
Dim NewShape As PowerPoint.Shape
Set NewShape = TheSlide.Shapes.AddPicture(ImageFile, msoFalse, msoTrue, 100, 100)
With NewShape
With .PictureFormat
.CropBottom = TheImage.PictureFormat.CropBottom
.CropLeft = TheImage.PictureFormat.CropLeft
.CropRight = TheImage.PictureFormat.CropRight
.CropTop = TheImage.PictureFormat.CropTop
.Brightness = TheImage.PictureFormat.Brightness
.ColorType = TheImage.PictureFormat.ColorType
.Contrast = TheImage.PictureFormat.Contrast
.TransparentBackground = TheImage.PictureFormat.TransparentBackground
End With
.Left = TheImage.Left
.Top = TheImage.Top
.Width = TheImage.Width
.Height = TheImage.Height
SetZPosition NewShape, TheImage.ZOrderPosition
With .AnimationSettings
.AdvanceMode = TheImage.AnimationSettings.AdvanceMode
.AdvanceTime = TheImage.AnimationSettings.AdvanceTime
.AfterEffect = TheImage.AnimationSettings.AfterEffect
.Animate = TheImage.AnimationSettings.Animate
.AnimateBackground = TheImage.AnimationSettings.AnimateBackground
.AnimateTextInReverse = TheImage.AnimationSettings.AnimateTextInReverse
.AnimationOrder = TheImage.AnimationSettings.AnimationOrder
.ChartUnitEffect = TheImage.AnimationSettings.ChartUnitEffect
.DimColor = TheImage.AnimationSettings.DimColor
.EntryEffect = TheImage.AnimationSettings.EntryEffect
With .PlaySettings
.ActionVerb = TheImage.AnimationSettings.PlaySettings.ActionVerb
.HideWhileNotPlaying = TheImage.AnimationSettings.PlaySettings.HideWhileNotPlaying
.LoopUntilStopped = TheImage.AnimationSettings.PlaySettings.LoopUntilStopped
.PauseAnimation = TheImage.AnimationSettings.PlaySettings.PauseAnimation
.PlayOnEntry = TheImage.AnimationSettings.PlaySettings.PlayOnEntry
.RewindMovie = TheImage.AnimationSettings.PlaySettings.RewindMovie
.StopAfterSlides = TheImage.AnimationSettings.PlaySettings.StopAfterSlides
End With
.TextLevelEffect = TheImage.AnimationSettings.TextLevelEffect
.TextUnitEffect = TheImage.AnimationSettings.TextUnitEffect
End With
End With
PROC_EXIT:
If Not TheImage Is Nothing Then TheImage.Delete
On Error GoTo 0
Exit Function
PROC_ERR:
MsgBox Err.Description
UpdateImage_BuildNewFromFile = False
GoTo PROC_EXIT
PROC_ERR_BELOW:
UpdateImage_BuildNewFromFile = False
GoTo PROC_EXIT
End Function