这应该可以帮助您前进。它将一个形状对象从一个打开的演示文稿复制到第二个打开的演示文稿,其中包含您想要的所有格式属性。实际上,您可以根据您要实现的目标使演示文稿、幻灯片和形状参考动态化,但这是一个演示原理的工作示例:
Option Explicit
' Macro to copy the first shape from the first slide of open presentation 1 to the first slide of open presentation 2
' Requires that 2 presetnations are open and that the first has a shape on slide 1
' Wriiten by Jamie Garroch of youpresent.co.uk
Sub PassTextBoxBetweenPresentations()
Dim oSrcShp As Shape ' Source Shape in Presentation 1
Dim oTgtShp As Shape ' Source Shape in Presentation 2
' Set a reference to a shape in the first presentation, in this case, the first shape on the first slide
Set oSrcShp = Presentations(1).Slides(1).Shapes(1)
' Copy the shape (with all of its properties) to the clipboard
oSrcShp.Copy
' Paste the shape from the first presentation to the second presentation
Presentations(2).Slides(1).Shapes.Paste
' Set a reference to the pasted shape
Set oTgtShp = Presentations(2).Slides(1).Shapes(Presentations(2).Slides(1).Shapes.Count)
' Do stuff with your pasted shape object
With oTgtShp
Dim headlines
If .HasTextFrame Then
If .TextFrame.HasText Then
headlines = .TextFrame.TextRange.Text
Debug.Print headlines
End If
End If
End With
' Clean up
Set oSrcShp = Nothing: Set oTgtShp = Nothing
End Sub