Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi, i'm new here so i would appreciate any assistance.
i have a spreadsheet that i would like to have a picture (selected by the user) inserted into a specific cell. The user will enter data in the spreadsheet and click a button to initiate the insert. The pictures may be of varying size but should not exceed 400x400 once inserted into the spreadsheet. Is this possible? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is some code I did for somebody else last week. Because your picture is
not square I test for which side is larger and then crop to 150. You have a choice of croping or scaling the picture to the size you want. below I cropped. to scale change the Width and Height of the picture instead of the crop commands. Sub InsertPict() PictureName = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If PictureName < False Then Set pict = ActiveSheet.Pictures. _ Insert(PictureName) pict.ShapeRange.LockAspectRatio = msoTrue 'pict.ShapeRange.Height = PictureHeight <=deleted pictwidth = pict.Width CellWidth = Cells(9, Cell.Column).Width WidthBorder = CellWidth - pictwidth pict.Left = Cells(9, Cell.Column).Left + (WidthBorder / 1.8) PictHeight = pict.Height CellHeight = Cells(9, Cell.Column).Height HeightBorder = CellHeight - PictHeight pict.Top = Cells(9, Cell.Column).Top + (HeightBorder / 1.8) 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 End If End Sub "jonm" wrote: hi, i'm new here so i would appreciate any assistance. i have a spreadsheet that i would like to have a picture (selected by the user) inserted into a specific cell. The user will enter data in the spreadsheet and click a button to initiate the insert. The pictures may be of varying size but should not exceed 400x400 once inserted into the spreadsheet. Is this possible? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I insert picture into cell so vlookup can return picture? | Excel Worksheet Functions | |||
insert a picture in to a comment but picture not save on hard disk | Excel Discussion (Misc queries) | |||
Insert Picture | Excel Discussion (Misc queries) | |||
How to insert a picture | Excel Discussion (Misc queries) | |||
insert picture | Excel Programming |