how do I copy the picture from 1 figure to another? in VBA

M

mmaatman

Hi,
I have a sheet with 2 figures
On one of them I have put a picture by choosing properties and clicking
a jpg at the picture property..
In VBA I want to duplicate the picture from this one to the other
figure

I have tried
worksheets(1).image2.picture = worksheets(1).image1.picture
But that doesnt do the job.

Any suggestions?

Thanks
Marcel (The Netherlands)
 
D

Dave Peterson

One way:

Option Explicit
Sub testme()
Dim myFPicture As Picture
Dim myTPicture As Picture

With Worksheets("sheet1")
Set myFPicture = .Pictures("Picture 1")
End With

myFPicture.Copy
With Worksheets("sheet2")
.Paste
Set myTPicture = .Pictures(.Pictures.Count)
End With

'same position & name?
With myTPicture
.Top = myFPicture.Top
.Left = myFPicture.Left
.Width = myFPicture.Width
.Height = myFPicture.Height
.Name = myFPicture.Name
End With

End Sub
 
Top