View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Secret Squirrel Secret Squirrel is offline
external usenet poster
 
Posts: 172
Default Move a picture with a vba macro

I'm using this code to insert a picture and resize it to the currently
selected cell. The problem is that the picture resizes but doesn't center in
the selected cell. How can I add this to my code so that picture will center
to the selected cell?

Sub InsertPicture()

Dim myPicture As String

myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", ,
"Select Picture to Import")
If myPicture < "" Then
ActiveSheet.Pictures.Insert (myPicture)
ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Selec t

With Selection

..ShapeRange.LockAspectRatio = msoFalse
..ShapeRange.Height = ActiveCell.RowHeight
..ShapeRange.Width = ActiveCell.ColumnWidth * 5.25 + 4
..Placement = xlMoveAndSize


End With
End If
End Sub