Pictures Inserting etc

  • Thread starter Thread starter David Holland
  • Start date Start date
D

David Holland

Hi

I have been working on a bit of VBA for inserting a Jpeg on a Workbook

The small problem I have is that I can size the picture to the size and
aspect ratio that I want.

This is the bit that I am using

ActiveSheet.Pictures.Insert(picturefilename).Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 60

Problem is that I just want to move it down just a bit.

My other request.

Is there any way of deleting all the pictures on a sheet. Without knowing
the picture number.


Thanks David
Nelson
New Zealand
 
David

Below is some code which uses a ShapeRange Collection. This allows you to
work on one 'Item' or the whole collection. You will have to step through
the code to see what it does or it will appear to do nothing. Set up three
images on your root drive (C:\) and open a standard workbook or rename a
sheet Sheet1. It inserts the images one after the other, selects them and
sets them to a ShapeRange collection, moves numbers two and three down 25
points and then deletes them all in one operation.

Sub ManipulatePictures()
Dim shpRng As ShapeRange
With Worksheets("Sheet1").Pictures
.Insert ("C:\Car1.jpg")
.Insert ("C:\Car2.jpg")
.Insert ("C:\Car3.jpg")
End With
Worksheets("Sheet1").Shapes.SelectAll
Set shpRng = Selection.ShapeRange
shpRng(2).IncrementTop 25
shpRng(3).IncrementTop 50
shpRng.Delete
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
Back
Top