Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default insert picture

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default insert picture

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
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 do I insert picture into cell so vlookup can return picture? ah Excel Worksheet Functions 1 May 1st 07 04:38 AM
insert a picture in to a comment but picture not save on hard disk Pablo Excel Discussion (Misc queries) 0 February 21st 07 03:48 PM
Insert Picture maximus73 Excel Discussion (Misc queries) 1 March 16th 06 12:16 AM
How to insert a picture Vance Porfirio Excel Discussion (Misc queries) 0 January 3rd 06 05:52 PM
insert picture chad Excel Programming 1 May 13th 04 01:35 AM


All times are GMT +1. The time now is 09:29 AM.

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

About Us

"It's about Microsoft Excel"