Arranging graphical objects on sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a program that copies several images and pastes them sequentially into
a single Excel sheet.

Does anyone have a function that can position each successive image
immediately below, but not overlapping the previously copied image? If you
could supply example code it would be most appreciated.
 
assign the top attribute of the new image to the sum of the top and height
attributes of the previous image.
 
Example copying pix from Sheet2 to Sheet1:

Dim shp As Shape, shpSh1 As Shape
Dim i
Sheet1.Select
Sheet1.Range("A1").Select
For Each shp In Sheet2.Shapes
shp.CopyPicture
Sheet1.Paste
i = Sheet1.Shapes.Count
Set shpSh1 = Sheet1.Shapes(i)
If i > 1 Then
shpSh1.Left = Sheet1.Shapes(i - 1).Left
shpSh1.Top = Sheet1.Shapes(i - 1).Top _
+ Sheet1.Shapes(i - 1).Height
'If you want to match th height and width too
' then keep below 2 lines, else delete them
shpSh1.Height = Sheet1.Shapes(i - 1).Height
shpSh1Width= Sheet1.Shapes(i - 1).Width
End If
Next

Sharad
 

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