【发布时间】:2014-12-17 08:25:41
【问题描述】:
希望您能提供帮助。以下是应该根据多次发送到过程 x 的形状创建新的 powerpoint 形状的快速子。当我尝试复制原始形状时,第二次出现类型不匹配错误。
Private Sub CreateOneEachPerDP(DPNumber As Integer, OneEach As Powerpoint.Shape)
Dim Count As Integer
Dim NewShape As Powerpoint.Shape
Dim TopOfFirstShape As Integer
Dim SpaceBtwShapes As Integer
For Count = 0 To DPNumber
If Count = 0 Then ' position first shape
'create new shape = OneEach type
Set NewShape = OneEach
With NewShape
.Top = TopOfFirstShape
.Left = 250
End With
Else ' position further shapes
Set NewShape = OneEach.Duplicate ' GIVES AN ERROR OF TYPE MISMATCH - WHY?
With NewShape
.Top = TopOfFirstShape + (Count * SpaceBtwShapes)
.Left = 250
End With
End If
'need to size according to text
With NewShape
.Width = 25
.Height = 20
End With
'load shape with text (if necessary)
Next Count
pwEnd Sub
【问题讨论】:
-
Duplicate返回类型ShapeRange,而不是Shape,所以不能将其返回值赋给NewShape
标签: vba shapes powerpoint type-mismatch