Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to "crop" charts created in Excel and moved to Word | Charts and Charting in Excel | |||
crop away the letters | Excel Discussion (Misc queries) | |||
crop spreadsheet | New Users to Excel | |||
Is there a way to crop text in an Excel cell? | Excel Discussion (Misc queries) | |||
I want to truncate/crop 3854502.2 into 545 in Excel. How do I do. | Excel Worksheet Functions |