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!