Pictures in Cells in Excel?

  • Thread starter Thread starter Joe 90
  • Start date Start date
J

Joe 90

Any way to make a picture stick/bind to a cell in Excel.

The handheld auditing program we use exports the data, including photos to
excel fine, and places the picture over the cell intended, top and left. I
know how to resize it to the size of the cell, but want to make it a bit
smaller than the cell and centre it on the cell to give a small border of
white space around it. I can make it smaller than the cell, but its still
top and left aligned to the cell. the only alignment adjustments I can find
work in relation to the sheet, and not to a cell?

Working in Excel 2000 (that's what my users have)

Thanks
 
Sub Tester2()
Dim pic As OLEObject
Dim rng As Range
Dim lBorder As Long
lBorder = 8
For Each pic In ActiveSheet.Pictures
Set rng = pic.TopLeftCell
pic.Top = rng.Top + lBorder
pic.Left = rng.Left + lBorder
pic.Width = rng.Width - 2 * lBorder
pic.Height = rng.Height - 2 * lBorder
Next

End Sub
 
Thanks

Will give it a go


Tom Ogilvy said:
Sub Tester2()
Dim pic As OLEObject
Dim rng As Range
Dim lBorder As Long
lBorder = 8
For Each pic In ActiveSheet.Pictures
Set rng = pic.TopLeftCell
pic.Top = rng.Top lBorder
pic.Left = rng.Left lBorder
pic.Width = rng.Width - 2 * lBorder
pic.Height = rng.Height - 2 * lBorder
Next

End Sub
 
Tom

Couldn't get this code to work, but was able to fix it by using:

mydocument = Worksheets(1)
For Each sh in mydocument.Shapes

and changing all the "pic" to "sh"

I still cannot figure out how to select a single shape based upon the range
it is in? e.g. if a picture is completely inside a cell, and this is the
activecell, how do I then select the picture within the cell with code?
(assume I have many rows each with a picture inside a cell) and I want to
work on only one picture, not the shapes collection.

regards

Joe
 
Back
Top