copy charts & paste as picture, hide chart, size & place same picture as chart

G

Gunnar Johansson

Hi,

I have 15 charts in one worksheet and want to go through them and have them
all unvisible put instead show a picture of them.

I have now tried to much of my own and would be grateful to any help, parts
or in whole. I have this code right now, but get error on line W "=
chtobj.Width" . I feel that it will not be the last debug error in it, so
please help me...


Private Sub CopyChart()
Application.EnableEvents = False
Application.ScreenUpdating = True

Dim chtobj As ChartObject
Dim W As Double
Dim H As Double
Dim T As Double
Dim L As Double
Dim Pic As Image

For Each chtobj In Sheet1.ChartObjects
W = chtobj.Width
H = chtobj.Height
L = chtobj.Left
T = chtobj.Top
chtobj.Visible = False
chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ActiveSheet.Pictures.Paste.Select
With Selection
.Width = W
.Height = H
.Left = L
.Top = T
End With
Next chtobj

Application.EnableEvents = False
Application.ScreenUpdating = True
Exit Sub

/Regards
 
T

Tim Williams

works for me...

Tim

Sub CopyChart()

Dim chtobj As ChartObject

ActiveSheet.Range("A1").Select
For Each chtobj In Sheet1.ChartObjects
chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ActiveSheet.Paste

With Selection
.Left = chtobj.Left
.Top = chtobj.Top
.Width = chtobj.Width
.Height = chtobj.Height
End With
chtobj.Visible = False
Next chtobj
End Sub
 
G

Gunnar Johansson

Thank you, it work for me to.

Could anybody please tell me how to delete the pictures? I can't find a
syntax to work to separate chartobjects from pictures.

A For each...Next modell would be handy. Anybody? Tim ?

Thanks again, Im on the track now.

/Regards
 
G

Gunnar Johansson

It was easy:
ActiveSheet.Pictures.Delete
Sorry to bother about that...

/Regards
 

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

Top