Thread: insert pictures
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default insert pictures

Try this code. Not sure how to reduce quality to 32K format. You need to
specify the height of the pictue in pixels. The program sets the row heigh
and then adjusts the picture size to fit the row height. the picture is
place on the worksheet based on the cells top and left properties. You may
want to make the picture a little bit smaller the then cell height.

pict.ShapeRange.Height = PictureHeight - 10

Also you may want the picture not to be at the top edge of the cell

pict.Top = Range("B" & RowCount).Top + 5


Sub add_pictures()

Const PictureHeight = 100

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Rows(1 & ":" & LastRow).RowHeight = PictureHeight

For RowCount = 1 To LastRow
Set pict = ActiveSheet.Pictures.Insert(Range("A" & RowCount))
pict.ShapeRange.LockAspectRatio = msoTrue
pict.ShapeRange.Height = PictureHeight
pict.Top = Range("B" & RowCount).Top
pict.Left = Range("B" & RowCount).Left
Next RowCount

End Sub
" wrote:

help please,

I need to insert pictures in excel using macro, I have picture names
in row1 (B1:G1) and I want to insert the pictures to row2 (B2:G2) each
cell has different file name, and I would want the pictures to be
resized to a 32 px and keep the ratio, and if possible be connected to
the cells.

thanks
marc