2013-03-29 15 views
0

我試圖用另一種類型(矩形形狀)的形狀對象替換幻燈片(圖片)上的所有形狀對象。我可以刪除舊對象並創建新對象,但是我將放棄所有動畫信息和序列順序。是否有可能在時間軸中存儲動畫信息和順序,並將其複製到新的形狀對象?在PowerPoint形狀之間複製動畫和序列信息

回答

2

嗯,我已經找到了自己的解決方案,希望有人能找到它有用。因此,不需要將動畫信息從舊形狀複製到新形狀,只需循環序列的項目並將形狀對象參考替換爲新形狀即可。像這樣:

On Error Resume Next 
Dim shp1 As Shape 'old shape 
Set shp1 = ActivePresentation.Slides(1).Shapes(3) 

Dim shp2 As Shape 'new shape 
Set shp2 = ActivePresentation.Slides(1).Shapes.AddPicture("c:\imgres2.jpg", msoFalse, msoTrue, 0, 0) 'it is important to create new shape before cycling through existing ones. 
For i = ActivePresentation.Slides(1).TimeLine.MainSequence.count To 1 Step -1 
    'using "is" opeartor to compare refrences 
    If shp1 Is ActivePresentation.Slides(1).TimeLine.MainSequence.Item(i).Shape Then 
     ActivePresentation.Slides(1).TimeLine.MainSequence.Item(i).Shape = shp2 
    End If 
Next i 
shp1.Delete 'delete the old shape 
0

嘗試是這樣的代碼,以動畫複製到新增加的形狀:

Sub PasteAnimationBehaviours() 

Dim SHP As Shape 'for existing shape 
Set SHP = ActivePresentation.Slides(1).Shapes(1) 
    SHP.PickupAnimation 


Dim newSHP As Shape 'pasting to new shape 
Set newSHP = ActivePresentation.Slides(1).Shapes.AddShape(msoShapeRectangle, 100, 100, 100, 100) 
    newSHP.ApplyAnimation 

End Sub 

添加評論後:如果您只需要更換形狀的類型嘗試使用這樣的:

Sub ShapeSubstition() 

Dim SHP As Shape 'for existing shape 
'test for 1st shape in 1st slide 
Set SHP = ActivePresentation.Slides(1).Shapes(1) 

SHP.AutoShapeType = msoShapeRectangle 'to rectangle 
SHP.AutoShapeType = msoShapeOval 'to oval 
End Sub 
+0

謝謝你的回答!但是它部分地解決了這個問題,但新的形狀動畫被添加到序列時間線的末尾。我如何將新形狀的動畫移動到指定的位置? – Andrey

0

我認爲使用「Animation Painter」命令按鈕複製動畫並將它們應用到另一個對象可能更容易。動畫畫家的功能與格式畫家相同。複製完所需動畫後,可以使用動畫窗格重新排列單個動畫。