Excel vba运行时错误1004复制图像 [英] Excel vba Run-time error 1004 copying images

查看:483
本文介绍了Excel vba运行时错误1004复制图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



通过编写代码可以正常运行,但通过寻址单元格运行有时会提供以下内容:

我有几个宏会在某些单元格值更改时复制和粘贴图像。错误:



运行时错误'1004':



Worksheet类的粘贴方法失败。 >

我使用以下代码复制图像:

  With Sheets(Quote )
.Shapes(ExampleQuoteImage)。复制
。激活
.Paste目的地:=范围(A102)
结束

我的开发机器上不会出现此错误,但在某些用户计算机上出现错误。



它每次都不会在同一行中断,但会在复制图像的任何位置中断。如果从中断点运行宏,则其余宏将正常运行。



可能是并发错误还是与剪贴板有关?

解决方案

尝试这个

  With ThisWorkbook $ s 
.Shapes(ExampleQuoteImage)。复制
DoEvents
.Paste目的地:=。范围(A102)
结束


I have several macros which copy and paste images when certain cell values are changed.

Stepping through the code works fine but running by addressing a cell sometimes gives the following error:

Run-Time error '1004':

Paste method of Worksheet class failed.

I use the following code to copy images:

    With Sheets("Quote")
    .Shapes("ExampleQuoteImage").Copy
    .Activate
    .Paste Destination:=Range("A102")
End With

The error doesn't occur on my development machine but does on some users machines.

It doesn't break at the same line every time but will break at any points where an image is copied. The rest of the macro runs normally if run it from the point at which it breaks.

Could it be a concurrency error or something to do with the clipboard?

解决方案

Try this

With ThisWorkbook.Sheets("Quote")
    .Shapes("ExampleQuoteImage").Copy
    DoEvents
    .Paste Destination:=.Range("A102") 
End With

这篇关于Excel vba运行时错误1004复制图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆