运行时错误1004工作表粘贴方法失败(有时发生)

时间:2014-07-22 04:43:14

标签: excel vba excel-vba

创建VBA程序,从[模板]工作表中复制形状,并使用for循环选择并复制和粘贴,粘贴到[显示]工作表。 它工作正常,但有时VBA错误[运行时错误1004工作表粘贴方法失败]

以下是我的源代码

Sub createDieProcess(partProcessRowCnt As Integer, dieProcessCD As String, 
    dieProcessPosition As Double, dieProcessWidth As Double)
Dim rShape As Shape
Dim pasteCell As String
    For Each rShape In Worksheets("TEMPLATE").Shapes
        If rShape.Name = dieProcessCD Then
            rShape.Copy
            pasteCell = "P" & partProcessRowCnt
            Range(pasteCell).Select
            ThisWorkbook.Sheets("Show").Paste 'The record when debug
            Selection.ShapeRange.IncrementTop 3
            Selection.ShapeRange.IncrementLeft dieProcessPosition
            Selection.ShapeRange.ScaleWidth dieProcessWidth, msoFalse
            Exit For
        End If
    Next
End Sub

我将不胜感激任何建议或意见。谢谢!

PS我尝试使用PasteSpecial,但它也显示相同的错误

0 个答案:

没有答案