Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to "crop" charts created in Excel and moved to Word Jim Charts and Charting in Excel 4 December 7th 09 01:57 PM
crop away the letters Fan924 Excel Discussion (Misc queries) 4 June 15th 09 05:51 PM
crop spreadsheet bekwud New Users to Excel 11 September 17th 06 10:35 PM
Is there a way to crop text in an Excel cell? cochranrg Excel Discussion (Misc queries) 6 December 13th 05 03:02 PM
I want to truncate/crop 3854502.2 into 545 in Excel. How do I do. billybob Excel Worksheet Functions 2 November 19th 04 03:53 AM


All times are GMT +1. The time now is 05:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"