PC Review


Reply
Thread Tools Rate Thread

copying all charts as enhanced metafiles

 
 
Paste charts as enchanced metafile
Guest
Posts: n/a
 
      9th Jun 2009
I have a sheet with a number of charts. I want to copy them to another sheet
as a single picture. The following code works, but the picture loses
resolution.

'Copies graphs as picture
Sheets("Graphs").Select
Range("A1:R51").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Range("A1").Select


'Pastes graph picture to summary sheet
Sheets("Static Summary Sheet").Select
Range("A1").Select
ActiveSheet.Paste

I have replaced the code with:

'Copies graphs as picture
Sheets("Graphs").Select
ActiveSheet.Shapes.SelectAll
Selection.Copy
Range("A1").Select


'Pastes graph picture to summary sheet
Sheets("Static Summary Sheet").Select
Range("D5").Select
ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
Link:=False _
, DisplayAsIcon:=False
Selection.Top = 69.75
Selection.Left = 37.5

Now I get an error in the pastespecial line "PasteSpecial method of
Worksheet class failed.

Any ideas?
 
Reply With Quote
 
 
 
 
Paste charts as enchanced metafile
Guest
Posts: n/a
 
      9th Jun 2009
I should add the loss of resolution is in Excel2007 and the error in the
second code is also in Excel2007. Both methods work fine in Excel2003.

"Paste charts as enchanced metafile" wrote:

> I have a sheet with a number of charts. I want to copy them to another sheet
> as a single picture. The following code works, but the picture loses
> resolution.
>
> 'Copies graphs as picture
> Sheets("Graphs").Select
> Range("A1:R51").Select
> Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
> Range("A1").Select
>
>
> 'Pastes graph picture to summary sheet
> Sheets("Static Summary Sheet").Select
> Range("A1").Select
> ActiveSheet.Paste
>
> I have replaced the code with:
>
> 'Copies graphs as picture
> Sheets("Graphs").Select
> ActiveSheet.Shapes.SelectAll
> Selection.Copy
> Range("A1").Select
>
>
> 'Pastes graph picture to summary sheet
> Sheets("Static Summary Sheet").Select
> Range("D5").Select
> ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
> Link:=False _
> , DisplayAsIcon:=False
> Selection.Top = 69.75
> Selection.Left = 37.5
>
> Now I get an error in the pastespecial line "PasteSpecial method of
> Worksheet class failed.
>
> Any ideas?

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      9th Jun 2009
I added two picture to a worksheet and used your code without any problems.
I'm using excel 2003.

Try the same thing. Add two pictures to a blank workbook and see if it
works. the code is good. Are both your sheets worksheets? You called one a
chart so was it created by adding a chart?



"Paste charts as enchanced metafile" wrote:

> I have a sheet with a number of charts. I want to copy them to another sheet
> as a single picture. The following code works, but the picture loses
> resolution.
>
> 'Copies graphs as picture
> Sheets("Graphs").Select
> Range("A1:R51").Select
> Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
> Range("A1").Select
>
>
> 'Pastes graph picture to summary sheet
> Sheets("Static Summary Sheet").Select
> Range("A1").Select
> ActiveSheet.Paste
>
> I have replaced the code with:
>
> 'Copies graphs as picture
> Sheets("Graphs").Select
> ActiveSheet.Shapes.SelectAll
> Selection.Copy
> Range("A1").Select
>
>
> 'Pastes graph picture to summary sheet
> Sheets("Static Summary Sheet").Select
> Range("D5").Select
> ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
> Link:=False _
> , DisplayAsIcon:=False
> Selection.Top = 69.75
> Selection.Left = 37.5
>
> Now I get an error in the pastespecial line "PasteSpecial method of
> Worksheet class failed.
>
> Any ideas?

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      9th Jun 2009
CopyPicture doesn't work correctly in Excel 2007, it has been reported.

Just use .Copy and all formats will be copied to the clipboard, then paste
with whichever format you want. More here -

http://groups.google.co.uk/group/mic...536ac8340331af

Regards,
Peter T


"Paste charts as enchanced metafile"
<(E-Mail Removed)> wrote in message
news:42E0EFA6-38D8-4BA0-AAC1-(E-Mail Removed)...
>I should add the loss of resolution is in Excel2007 and the error in the
> second code is also in Excel2007. Both methods work fine in Excel2003.
>
> "Paste charts as enchanced metafile" wrote:
>
>> I have a sheet with a number of charts. I want to copy them to another
>> sheet
>> as a single picture. The following code works, but the picture loses
>> resolution.
>>
>> 'Copies graphs as picture
>> Sheets("Graphs").Select
>> Range("A1:R51").Select
>> Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
>> Range("A1").Select
>>
>>
>> 'Pastes graph picture to summary sheet
>> Sheets("Static Summary Sheet").Select
>> Range("A1").Select
>> ActiveSheet.Paste
>>
>> I have replaced the code with:
>>
>> 'Copies graphs as picture
>> Sheets("Graphs").Select
>> ActiveSheet.Shapes.SelectAll
>> Selection.Copy
>> Range("A1").Select
>>
>>
>> 'Pastes graph picture to summary sheet
>> Sheets("Static Summary Sheet").Select
>> Range("D5").Select
>> ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
>> Link:=False _
>> , DisplayAsIcon:=False
>> Selection.Top = 69.75
>> Selection.Left = 37.5
>>
>> Now I get an error in the pastespecial line "PasteSpecial method of
>> Worksheet class failed.
>>
>> Any ideas?



 
Reply With Quote
 
Paste charts as enchanced metafile
Guest
Posts: n/a
 
      9th Jun 2009
Joel,

The code works fine in 2003, not in 2007.

"Joel" wrote:

> I added two picture to a worksheet and used your code without any problems.
> I'm using excel 2003.
>
> Try the same thing. Add two pictures to a blank workbook and see if it
> works. the code is good. Are both your sheets worksheets? You called one a
> chart so was it created by adding a chart?
>
>
>
> "Paste charts as enchanced metafile" wrote:
>
> > I have a sheet with a number of charts. I want to copy them to another sheet
> > as a single picture. The following code works, but the picture loses
> > resolution.
> >
> > 'Copies graphs as picture
> > Sheets("Graphs").Select
> > Range("A1:R51").Select
> > Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
> > Range("A1").Select
> >
> >
> > 'Pastes graph picture to summary sheet
> > Sheets("Static Summary Sheet").Select
> > Range("A1").Select
> > ActiveSheet.Paste
> >
> > I have replaced the code with:
> >
> > 'Copies graphs as picture
> > Sheets("Graphs").Select
> > ActiveSheet.Shapes.SelectAll
> > Selection.Copy
> > Range("A1").Select
> >
> >
> > 'Pastes graph picture to summary sheet
> > Sheets("Static Summary Sheet").Select
> > Range("D5").Select
> > ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
> > Link:=False _
> > , DisplayAsIcon:=False
> > Selection.Top = 69.75
> > Selection.Left = 37.5
> >
> > Now I get an error in the pastespecial line "PasteSpecial method of
> > Worksheet class failed.
> >
> > Any ideas?

 
Reply With Quote
 
Paste charts as enchanced metafile
Guest
Posts: n/a
 
      9th Jun 2009
Peter,

..Copy works for a single chart. Any way to select all the charts and paste
them all at once?

"Peter T" wrote:

> CopyPicture doesn't work correctly in Excel 2007, it has been reported.
>
> Just use .Copy and all formats will be copied to the clipboard, then paste
> with whichever format you want. More here -
>
> http://groups.google.co.uk/group/mic...536ac8340331af
>
> Regards,
> Peter T
>
>
> "Paste charts as enchanced metafile"
> <(E-Mail Removed)> wrote in message
> news:42E0EFA6-38D8-4BA0-AAC1-(E-Mail Removed)...
> >I should add the loss of resolution is in Excel2007 and the error in the
> > second code is also in Excel2007. Both methods work fine in Excel2003.
> >
> > "Paste charts as enchanced metafile" wrote:
> >
> >> I have a sheet with a number of charts. I want to copy them to another
> >> sheet
> >> as a single picture. The following code works, but the picture loses
> >> resolution.
> >>
> >> 'Copies graphs as picture
> >> Sheets("Graphs").Select
> >> Range("A1:R51").Select
> >> Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
> >> Range("A1").Select
> >>
> >>
> >> 'Pastes graph picture to summary sheet
> >> Sheets("Static Summary Sheet").Select
> >> Range("A1").Select
> >> ActiveSheet.Paste
> >>
> >> I have replaced the code with:
> >>
> >> 'Copies graphs as picture
> >> Sheets("Graphs").Select
> >> ActiveSheet.Shapes.SelectAll
> >> Selection.Copy
> >> Range("A1").Select
> >>
> >>
> >> 'Pastes graph picture to summary sheet
> >> Sheets("Static Summary Sheet").Select
> >> Range("D5").Select
> >> ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
> >> Link:=False _
> >> , DisplayAsIcon:=False
> >> Selection.Top = 69.75
> >> Selection.Left = 37.5
> >>
> >> Now I get an error in the pastespecial line "PasteSpecial method of
> >> Worksheet class failed.
> >>
> >> Any ideas?

>
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      9th Jun 2009
What a palava!

Sub test()
Dim i As Long
Dim arr()
Dim wsSource As Worksheet, wsDest As Worksheet

Set wsSource = Worksheets("Sheet1")
Set wsDest = Worksheets("Sheet2")

wsSource.Activate
With wsSource.ChartObjects
ReDim arr(1 To .Count)

For i = 1 To UBound(arr)
arr(i) = .Item(i).ZOrder
Next
End With

wsSource.DrawingObjects(arr).Select
wsSource.DrawingObjects(arr).Copy

wsDest.Activate
wsDest.Range("B2").Activate
wsDest.PasteSpecial Format:="Picture (Enhanced Metafile)"

End Sub

Lots of select/activate and other stuff in the above I'd normally be
advising people not to do - but if needs must for Excel 2007 !

Regards,
Peter T

"Paste charts as enchanced metafile"
<(E-Mail Removed)> wrote in message
news:734F0956-10A5-4DD2-8FC6-(E-Mail Removed)...
> Peter,
>
> .Copy works for a single chart. Any way to select all the charts and paste
> them all at once?
>
> "Peter T" wrote:
>
>> CopyPicture doesn't work correctly in Excel 2007, it has been reported.
>>
>> Just use .Copy and all formats will be copied to the clipboard, then
>> paste
>> with whichever format you want. More here -
>>
>> http://groups.google.co.uk/group/mic...536ac8340331af
>>
>> Regards,
>> Peter T
>>
>>
>> "Paste charts as enchanced metafile"
>> <(E-Mail Removed)> wrote in
>> message
>> news:42E0EFA6-38D8-4BA0-AAC1-(E-Mail Removed)...
>> >I should add the loss of resolution is in Excel2007 and the error in the
>> > second code is also in Excel2007. Both methods work fine in Excel2003.
>> >
>> > "Paste charts as enchanced metafile" wrote:
>> >
>> >> I have a sheet with a number of charts. I want to copy them to another
>> >> sheet
>> >> as a single picture. The following code works, but the picture loses
>> >> resolution.
>> >>
>> >> 'Copies graphs as picture
>> >> Sheets("Graphs").Select
>> >> Range("A1:R51").Select
>> >> Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
>> >> Range("A1").Select
>> >>
>> >>
>> >> 'Pastes graph picture to summary sheet
>> >> Sheets("Static Summary Sheet").Select
>> >> Range("A1").Select
>> >> ActiveSheet.Paste
>> >>
>> >> I have replaced the code with:
>> >>
>> >> 'Copies graphs as picture
>> >> Sheets("Graphs").Select
>> >> ActiveSheet.Shapes.SelectAll
>> >> Selection.Copy
>> >> Range("A1").Select
>> >>
>> >>
>> >> 'Pastes graph picture to summary sheet
>> >> Sheets("Static Summary Sheet").Select
>> >> Range("D5").Select
>> >> ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
>> >> Link:=False _
>> >> , DisplayAsIcon:=False
>> >> Selection.Top = 69.75
>> >> Selection.Left = 37.5
>> >>
>> >> Now I get an error in the pastespecial line "PasteSpecial method of
>> >> Worksheet class failed.
>> >>
>> >> Any ideas?

>>
>>
>>



 
Reply With Quote
 
Paste charts as enchanced metafile
Guest
Posts: n/a
 
      9th Jun 2009
Thanks for your help.

"Peter T" wrote:

> What a palava!
>
> Sub test()
> Dim i As Long
> Dim arr()
> Dim wsSource As Worksheet, wsDest As Worksheet
>
> Set wsSource = Worksheets("Sheet1")
> Set wsDest = Worksheets("Sheet2")
>
> wsSource.Activate
> With wsSource.ChartObjects
> ReDim arr(1 To .Count)
>
> For i = 1 To UBound(arr)
> arr(i) = .Item(i).ZOrder
> Next
> End With
>
> wsSource.DrawingObjects(arr).Select
> wsSource.DrawingObjects(arr).Copy
>
> wsDest.Activate
> wsDest.Range("B2").Activate
> wsDest.PasteSpecial Format:="Picture (Enhanced Metafile)"
>
> End Sub
>
> Lots of select/activate and other stuff in the above I'd normally be
> advising people not to do - but if needs must for Excel 2007 !
>
> Regards,
> Peter T
>
> "Paste charts as enchanced metafile"
> <(E-Mail Removed)> wrote in message
> news:734F0956-10A5-4DD2-8FC6-(E-Mail Removed)...
> > Peter,
> >
> > .Copy works for a single chart. Any way to select all the charts and paste
> > them all at once?
> >
> > "Peter T" wrote:
> >
> >> CopyPicture doesn't work correctly in Excel 2007, it has been reported.
> >>
> >> Just use .Copy and all formats will be copied to the clipboard, then
> >> paste
> >> with whichever format you want. More here -
> >>
> >> http://groups.google.co.uk/group/mic...536ac8340331af
> >>
> >> Regards,
> >> Peter T
> >>
> >>
> >> "Paste charts as enchanced metafile"
> >> <(E-Mail Removed)> wrote in
> >> message
> >> news:42E0EFA6-38D8-4BA0-AAC1-(E-Mail Removed)...
> >> >I should add the loss of resolution is in Excel2007 and the error in the
> >> > second code is also in Excel2007. Both methods work fine in Excel2003.
> >> >
> >> > "Paste charts as enchanced metafile" wrote:
> >> >
> >> >> I have a sheet with a number of charts. I want to copy them to another
> >> >> sheet
> >> >> as a single picture. The following code works, but the picture loses
> >> >> resolution.
> >> >>
> >> >> 'Copies graphs as picture
> >> >> Sheets("Graphs").Select
> >> >> Range("A1:R51").Select
> >> >> Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
> >> >> Range("A1").Select
> >> >>
> >> >>
> >> >> 'Pastes graph picture to summary sheet
> >> >> Sheets("Static Summary Sheet").Select
> >> >> Range("A1").Select
> >> >> ActiveSheet.Paste
> >> >>
> >> >> I have replaced the code with:
> >> >>
> >> >> 'Copies graphs as picture
> >> >> Sheets("Graphs").Select
> >> >> ActiveSheet.Shapes.SelectAll
> >> >> Selection.Copy
> >> >> Range("A1").Select
> >> >>
> >> >>
> >> >> 'Pastes graph picture to summary sheet
> >> >> Sheets("Static Summary Sheet").Select
> >> >> Range("D5").Select
> >> >> ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
> >> >> Link:=False _
> >> >> , DisplayAsIcon:=False
> >> >> Selection.Top = 69.75
> >> >> Selection.Left = 37.5
> >> >>
> >> >> Now I get an error in the pastespecial line "PasteSpecial method of
> >> >> Worksheet class failed.
> >> >>
> >> >> Any ideas?
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enhanced Metafiles in Word 2003 =?Utf-8?B?T3V0bG9vayBDb252ZXJ0?= Microsoft Word New Users 1 21st Jun 2007 10:30 PM
Distorted Arial font in enhanced metafiles =?Utf-8?B?VmFuZXNzYQ==?= Microsoft Word Document Management 3 28th Aug 2006 02:36 PM
Enhanced Metafiles =?Utf-8?B?QmFycnk=?= Microsoft Dot NET 0 4th Jan 2005 01:03 PM
Enhanced Metafiles =?Utf-8?B?QmFycnk=?= Microsoft Dot NET 0 20th Dec 2004 01:17 PM
Pasting Excel Charts as Enhanced Metafiles Donahue Microsoft Excel Charting 4 8th Sep 2004 11:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:10 PM.