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

  • Thread starter Thread starter mmaatman
  • Start date Start date
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)
 
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
 

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