Object pasting causes 1004 error (only on a single machine) Please help.

brightsites

New Member
Joined
Sep 19, 2012
Messages
6
Hi Guys,

This is my very first post on this fine forum and was hoping someone may be able to shed some light on this error.

I've built a system for creating reports, its built in excel 2010 and works perfectly on 2010 and 2007 (on about 10 different machines). The problem is a single machine.. Part of the code runs through all the tabs in the report and converts all objects (graphs etc) into JPEG's and then exports the report into a new workbook ready for sending.

The section of code causing and error is as follows: (Runtime 1004 error caused at ".Paste")

Code:
   With Worksheets("Organic Traffic")
    For Each chtO In .ChartObjects
        chtO.CopyPicture
        .Paste
        With .Shapes(.Shapes.Count)
            .Top = chtO.Top
            .Left = chtO.Left
            .Name = chtO.Name & "_pic"
       
     '      'Application.Wait Now + TimeValue("00:00:01")
         
        End With
        chtO.Delete
    Next chtO
End With

Another strange part of this is that if you step through the code with the debugger, no errors are caused and also if you simply hit debug and resume the code runs as it should (without error)

I feel like I have tried everything, we have several machines using the same version of excel 2010 without error.

Would REALLLY appreciate any help you can provide.

Many thanks

BrightSites
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Is that machine setup exactly like the other machines, or could it perhaps have more memory allocated elsewhere?
 
Upvote 0
Maybe try adding DoEvents between CopyPicture and Paste or clearing the ClipBoard after each Paste. I found quite a few examples of your problem by Googling for 'error 1004 copypicture paste'.
 
Upvote 0
I am quite certain that what Andrew Poulsom gave you, will solve the problem.

Thank you AP!:)
 
Upvote 0
Hi Andrew,

Thanks for the reply, Can you tell me abit more about DoEvents? What does this do?

Ive added Application.CutCopyMode = False to clear the clipboard, does this seem correct?

Again, many thanks

Maybe try adding DoEvents between CopyPicture and Paste or clearing the ClipBoard after each Paste. I found quite a few examples of your problem by Googling for 'error 1004 copypicture paste'.
 
Upvote 0
According to VBA Help DoEvents yields execution so that the operating system can process other events.

Your code to clear the clipboard is correct.
 
Upvote 0
Andrew Poulsom - You sir.... are a legend. thank you so very much. All seems to be working perfectly. Many many thanks
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top