ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adjusting the size of a picture (https://www.excelbanter.com/excel-programming/424946-adjusting-size-picture.html)

Brad

Adjusting the size of a picture
 
I have the following code to insert photos into a workbook. I want to be able
to stretch the photo to fill up the range. The following code works great at
inserting the pictures, but I think that the aspect ratio of the photo is
locked so the picture doesn't stretch to fill the area. Is there anyway to
change that?

Workbooks("Dots").Activate
For c = 1 To 5
Sheets("Sheet" & c).Activate
Range("A42").Select
Set photo(c) = ActiveSheet.Pictures.Insert(picLocation(c))
With photo(c)
.Top = ActiveCell.Top
.Left = ActiveCell.Left
.Width = ActiveCell.Offset(14, 46).Left - .Left
.Height = ActiveCell.Offset(14, 46).Top - .Top
End With
Next

joel

Adjusting the size of a picture
 
I used the macro recorder to get this line

Selection.ShapeRange.LockAspectRatio = msoFalse

so you should have

photo(c).ShapeRange.LockAspectRatio = msoFalse

"Brad" wrote:

I have the following code to insert photos into a workbook. I want to be able
to stretch the photo to fill up the range. The following code works great at
inserting the pictures, but I think that the aspect ratio of the photo is
locked so the picture doesn't stretch to fill the area. Is there anyway to
change that?

Workbooks("Dots").Activate
For c = 1 To 5
Sheets("Sheet" & c).Activate
Range("A42").Select
Set photo(c) = ActiveSheet.Pictures.Insert(picLocation(c))
With photo(c)
.Top = ActiveCell.Top
.Left = ActiveCell.Left
.Width = ActiveCell.Offset(14, 46).Left - .Left
.Height = ActiveCell.Offset(14, 46).Top - .Top
End With
Next



All times are GMT +1. The time now is 02:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com