View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default I get two copies of pictures in the loop instead of one - why?

What triggers your macro? Maybe you are running it twice.

--
Regards,
Tom Ogilvy

"Maria High" wrote in message
...
Hi,

I have a sheet where I in Worksheet_Activate copy all chartobjects and

paste
them as pictures and then hide the chartobjects. This make the users not
able to ruin the references in the charts.

Problem: I get two copies of pictures...why????

She sheet1 had to have a couple of charts. Code:

Sub CopyChart()
Dim chtobj As ChartObject
Dim W As Double
Dim H As Double
Dim T As Double
Dim L As Double

ActiveSheet.Unprotect
ActiveSheet.Pictures.Delete

For Each chtobj In Sheet1.ChartObjects
W = chtobj.Width
H = chtobj.Height
L = chtobj.Left
T = chtobj.Top
chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture

ActiveSheet.Pictures.Paste.Select
With Selection
.Width = W
.Height = H
.Left = L
.Top = T
End With
Next chtobj

ActiveSheet.ChartObjects.Visible = False
Exit Sub

/Regards