View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Finny[_2_] Finny[_2_] is offline
external usenet poster
 
Posts: 1
Default Center All Pictures in Excel Cells

Please help. Right now I have a UDF that I found online that lets me
insert a picture into a cell by referencing the exact location on my
hard drive where the picture resides. I also have a macro that if I
select a shape # and range value, it will center that shape in the
cell for which is referenced.

Is there a way to combine these two codes to get it to insert the
picture and also center the picture perfectly within the cell? I can
get the first code to add as many pictures as I reference, but then I
am at a loss with centering them all within the cells.

Any help that you can provide would be greatly appreciated.


<<<<INSERT PICTURE CODE START

Function ShowPic(PicFile As String) As Boolean
Dim AC As Range
Dim shp As Shape
On Error GoTo Done
Set AC = Application.Caller
ActiveSheet.Shapes.AddPicture PicFile, True, True, AC.Left, AC.Top, 5,
5
ShowPic = True
Exit Function
Done:
ShowPic = False
End Function

<<<<INSERT PICTURE CODE END

<<<<CENTER PICTURE CODE START
Sub aTest()
CenterMe ActiveSheet.Shapes(1), Range("b8")
End Sub

Sub CenterMe(shp As Shape, overcells As Range)

With overcells
shp.Left = .Left + ((.Width - shp.Width) / 2)
shp.Top = .Top + ((.Height - shp.Height) / 2)
End With
End Sub

<<<<CENTER PICTURE CODE END