View Single Post
 
Old 12-05-2008, 07:33 PM
Emily Emily is offline
Novice
 
Join Date: Dec 2008
Location: Hong Kong
Posts: 7
Emily is on a distinguished road
Default

Code:
 
Sub TestInsertPictureInCell()
InsertPictureInRange "D:\Happy1.jpg", Range("A1")
End Sub


Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range)
Dim p As Object

If Dir(PictureFileName) = "" Then Exit Sub

Set p = ActiveSheet.Pictures.Insert(PictureFileName)

With TargetCells
    p.Top = .Top
    p.Left = .Left
    .ColumnWidth = .ColumnWidth / .Width * p.Width
    .RowHeight = p.Height  ' < 409 pixels
End With

Set p = Nothing
End Sub
Reply With Quote