Bob Phillips, please help more one Sheets.add continued

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi Bob,
I've implemented what you had suggested,but I have this
problem now....any help?

I have the following code for copying a chart and pasting
it as a picture into newly created sheet.

The problem are two fold:
1) it seems to take a long time for it to be copied (like
5 seconds or so for each chart)

2) Nothing visible gets pasted?

Anyone knows what's going on here please?

Private Sub Cmd_AddShCopyChrts_Click()
Dim wsMySheet As Worksheet

Sheets("Charts").Select

ActiveSheet.Shapes("Chart 1").Select

Selection.Copy

Set wsMySheet = Worksheets.Add

wsMySheet.Select

ActiveSheet.PasteSpecial Format:="Picture (Enhanced
Metafile)", Link:=False _
, DisplayAsIcon:=False


End Sub
 
First, get rid of all the Selects. They just slow everything down.

Private Sub Cmd_AddShCopyChrts_Click()
Dim wsMySheet As Worksheet

Set wsMySheet = Worksheets.Add
Sheets("Charts").Shapes("Chart 1").Copy
wsMySheet.PasteSpecial _
Format:="Picture (Enhanced Metafile)", _
Link:=False, _
DisplayAsIcon:=False
End Sub
 
Thank you very much sir.

This works now with a charm.
If you get a chance, can you explain to me why it wasn't
working before?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top