Cannot use the Range.Copypicture method to copy the contents from a Excel to a MS Word document in office 2010.

I am using the Microsoft.Interop.Excel.range.Copypicture method to get the contents from the Excel File to a MS Word file, programmatically.

I have been using the same logic in earlier version of Office (2007 and 2003), and it was working fine.

But using the same application with Office 2010 is throwing the error, and i could not complete the task.The Error raised when using this method is "Copy picture method of range class failed".

Any help would be appreciated..

 

Thanks

Naveen Joseph

I have used CopyPicture successfully in Excel 2010.

Does changing the arguments of CopyPicture method change the result?

Sometimes, for example, using xlPrinter rather than xlScreen (or vice versa) can avoid such an error.


Bill Manville. Excel MVP, Oxford, England. www.manville.org.uk
Microsoft Excel MVP, Oxford, England. www.manville.org.uk

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Actually i did change the parameters and tried it, but it didn't helped.

 

Have you tried out this in office 2010?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Yes.  I use CopyPicture extensively in many of my applications.

Perhaps you could describe more of the circumstances in which it fails?


Bill Manville. Excel MVP, Oxford, England. www.manville.org.uk

Microsoft Excel MVP, Oxford, England. www.manville.org.uk

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

We are looping through the Excel files and Copying the contents from the Excel File to a single  Word File. The Same application is working good with office 2003 and Office 2007. But Now when we are installed Office 2010,this issue was seen.

As noted before I played with optional parameters but was not successful.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I can't be much further help without more information.
If you can send me the code that is failing for you, and a workbook on which it fails, I could try it and see if I can reproduce the problem.

You can get to my email address through the Contact page on my web site


Bill Manville. Excel MVP, Oxford, England. www.manville.org.uk
Microsoft Excel MVP, Oxford, England. www.manville.org.uk

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I Created a sample app, and tried this,though I got the error when I used the xlprinter as parameter, when i changed it to xlScreen, the error dissapeared.

"r.CopyPicture(Microsoft.Office.Interop.Excel.XlPictureAppearance.xlScreen , XlCopyPictureFormat.xlPicture);"

But the same code in main app is throwing error, So it seems the issue was specific to my project, though I have to find why it is breaking in my case :).

Anyways thanks for the help Bill.

Thanks & Regards

Naveen Joseph Panakkal

 

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Naveen,

  What was your final resolution regarding Chart.CopyPicture.  I'm converting code from Excel2003 to Excel2010 and am encountering the same problem. 

Please note that behaviors may be influenced by whether the chart is in a sheet or is the whole sheet. Also multiple charts impact this too.

Note also how microsoft makes working with their products so easy by documenting all of the issues with each method as an addendum to it's orignal reference page.  (But of course, I kid).

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I am using the Microsoft.Interop.Excel.range.Copypicture method to get the contents from the Excel File to a MS Word file, programmatically.

I have been using the same logic in earlier version of Office (2007 and 2003), and it was working fine.

But using the same application with Office 2010 is throwing the error, and i could not complete the task.The Error raised when using this method is "Copy picture method of range class failed".

Any help would be appreciated..

Thanks

Naveen Joseph

I had this problem for quite a while. My old codes seemed work 70% of the time and I searched online and found one solution that finally solved the problem - to activate the source worksheet before you execute the Range("yourchartrange").copyPicture method.

I can only guess the cause - the Charts on top of the named range are technically not part of the range.

Without the sheet activated, the code "srcWkbk.Sheets(sSheet).Range(sRange).Select " doesnot work all the time, neither will this line "srcWkbk.Sheets(sSheet).Range(sRange).CopyPicture" work. 

These codes were the codes that gave me trouble:

    srcWkbk.Activate
    srcWkbk.Sheets(sSheet).Range(sRange).CopyPicture Appearance:=xlScreen, Format:=xlPicture
    tgtWkbk.Sheets(sSheet).Paste Destination:=Sheets(sSheet).Range("A1")

I inserted two lines that solved the problem:

        srcWkbk.Activate

        srcWkbk.Sheets(sSheet).Activate                                      'activate the source worksheet first
        srcWkbk.Sheets(sSheet).Range(sRange).Select                'so this line will work

        srcWkbk.Sheets(sSheet).Range(sRange).CopyPicture Appearance:=xlScreen, Format:=xlPicture
        tgtWkbk.Sheets(sSheet).Paste Destination:=Sheets(sSheet).Range("A1")

Hope the above helps! 

6 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated December 14, 2023 Views 5,786 Applies to: