April 2006
Beginner
1114 pages
98h 16m
English
Use the AddPicture method to insert a picture as a shape. Pictures are treated like any other shape, so Shape methods like Flip work fine. In addition, picture shapes have a PictureFormat property that you can use to adjust brightness, transparency, and other attributes of the picture. The following code inserts a logo on the active worksheet, flips it, and makes its background transparent:
Sub InsertPicture( )
Dim ws As Worksheet, s As Shape
Set ws = ActiveSheet
' Insert the image.
Set s = ws.Shapes.AddPicture(ThisWorkbook.Path & "\logo.bmp", _
False, True, 120, 170, 100, 100)
' Flip the image.
s.Flip msoFlipHorizontal
' The picture background is white.
s.PictureFormat.TransparencyColor = &HFFFFFF
' Turn on transparency.
s.PictureFormat.TransparentBackground = True
End SubRead now
Unlock full access