Crop pictures in excel,,,
Hi, I have a Macro that inserts pictures in excel, but my pictures are some in different sizes some have the width long and some the height is long. What I need is a macro that sizes the pictures. If the width is longer than the height then CROP the width from the RIGHT and the LEFT to the same size as the Height. And same for the height, if the Height is longer than the width then Crop from the TOP and the BOTTOM to the same size as the Width. This is the part of the Macro that I have now. If Pict.Width Pict.Height Then Crop = (CellWidth - Pict.Width) / 2 Pict.ShapeRange.PictureFormat.CropLeft = 150 Pict.ShapeRange.PictureFormat.CropRight = 150 Else Crop = (CellHeight - Pict.Height) / 2 Pict.ShapeRange.PictureFormat.CropTop = 150 Pict.ShapeRange.PictureFormat.CropBottom = 150 End If |
Crop pictures in excel,,,
Here is two slightly different solutions
If pict.Width pict.Height Then If pict.Width CellWidth Then If pict.Width 150 Then Crop = (pict.Width - CellWidth) / 2 pict.ShapeRange.PictureFormat.CropLeft = Crop pict.ShapeRange.PictureFormat.CropRight = Crop End If End If Else If CellHeight pict.Height Then If pict.Height 150 Then Crop = Abs(pict.Height - CellHeight) / 2 pict.ShapeRange.PictureFormat.CropTop = Crop pict.ShapeRange.PictureFormat.CropBottom = Crop End If End If End If If pict.Width pict.Height Then If pict.Width 150 Then Crop = (pict.Width - 150) / 2 pict.ShapeRange.PictureFormat.CropLeft = Crop pict.ShapeRange.PictureFormat.CropRight = Crop End If Else If pict.Height 150 Then Crop = (pict.Height - 150) / 2 pict.ShapeRange.PictureFormat.CropTop = Crop pict.ShapeRange.PictureFormat.CropBottom = Crop End If End If " wrote: Hi, I have a Macro that inserts pictures in excel, but my pictures are some in different sizes some have the width long and some the height is long. What I need is a macro that sizes the pictures. If the width is longer than the height then CROP the width from the RIGHT and the LEFT to the same size as the Height. And same for the height, if the Height is longer than the width then Crop from the TOP and the BOTTOM to the same size as the Width. This is the part of the Macro that I have now. If Pict.Width Pict.Height Then Crop = (CellWidth - Pict.Width) / 2 Pict.ShapeRange.PictureFormat.CropLeft = 150 Pict.ShapeRange.PictureFormat.CropRight = 150 Else Crop = (CellHeight - Pict.Height) / 2 Pict.ShapeRange.PictureFormat.CropTop = 150 Pict.ShapeRange.PictureFormat.CropBottom = 150 End If |
All times are GMT +1. The time now is 10:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com