2003 macro working in 2007 - inserting a jpeg

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have written the following code which inserts a jpeg file in a cell
(B171)


If Range("R4") = "DW" Then
Range("B171").Value = "Dave Woodgate"
Range("B171").Select
ActiveCell.Select
ActiveSheet.Pictures.Insert("S:\Tsunami Axis\Purchase Orders\Sigs
\Dave Woodgate.JPG").Select
Selection.ShapeRange.PictureFormat.TransparentBackground = msoTrue
Selection.ShapeRange.PictureFormat.TransparencyColor = RGB(255,
255, 255)
Selection.ShapeRange.Fill.Visible = msoFalse
End If


this all works perfectly in 2003, however when the macro is run in
2007 the jpeg is inserted in B4(ish). How do I get it to line up with
the left top of B171? All help appreciated

Thanks

Dave
 
In 2007 it not use the position of the acivecell

Use it like this

Dim myPict As Picture

With ActiveSheet.Range("B171")
Set myPict = .Parent.Pictures.Insert("S:\Tsunami Axis\Purchase Orders\Sigs\Dave Woodgate.JPG")
myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With
 
Thanks for this, Ron
--
Bernard

Ron de Bruin said:
In 2007 it not use the position of the acivecell

Use it like this

Dim myPict As Picture
With ActiveSheet.Range("B171")
Set myPict = .Parent.Pictures.Insert("S:\Tsunami Axis\Purchase
Orders\Sigs\Dave Woodgate.JPG")
myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With
 
Back
Top