我在将图像从一个工作表复制和粘贴到另一个工作表时遇到了问题。此代码适用于PC,但不适用于Mac!当我在Mac上运行它时,我得到了一个错误1004。
这是一个复制/粘贴图像的问题!我已经看过很多论坛了,但什么都不能用!
下面是我的代码:
Dim sh As Shape
For Each sh In Sheets("Settings").Shapes
Debug.Print sh.Name
If sh.Name = reportname Then ' give the name of your Picture here
sh.Copy
With Sheets(reportname)
.Select
.Range("A1").Select
.PasteSpecial
End With
Application.CutCopyMode = False
End If
Next错误发生在.PasteSpecial行上,并且再次出现错误1004。
发布于 2014-09-11 06:48:52
试试这个,这对我来说似乎很管用。
Sub Test()
Dim shp As Shape
For Each shp In Sheets("Settings").Shapes
If shp.Type = 13 Then
retry:
shp.Copy
On Error Resume Next
Sheets(shp.Name).PasteSpecial
If Err.Number = 9 Then
Sheets.Add(after:=Sheets(Sheets.Count)).Name = shp.Name
GoTo retry
End If
On Error GoTo 0
End If
Next
End Subhttps://stackoverflow.com/questions/25755276
复制相似问题