J
Josip.2000
Hi, can somebody help me with this piece of code and tell me how I can
get it to work in both Excel 2002 and 2007?
Sub Autpen()
InsertPictureInRange "___URL_to_picture_on_the_net___", _
Range("G21:J29")
End Sub
Sub InsertPictureInRange(PictureFileName As String, TargetCells As
Range)
Dim p As Object, t As Double, l As Double, w As Double, h As Double
If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
Set p = ActiveSheet.Pictures.Insert(PictureFileName)
With TargetCells
t = .Top
l = .Left
w = .Offset(0, .Columns.Count).Left - .Left
h = .Offset(.Rows.Count, 0).Top - .Top
End With
With p
.Top = t
.Left = l
.Width = w
.Height = h
End With
Set p = Nothing
End Sub
get it to work in both Excel 2002 and 2007?
Sub Autpen()
InsertPictureInRange "___URL_to_picture_on_the_net___", _
Range("G21:J29")
End Sub
Sub InsertPictureInRange(PictureFileName As String, TargetCells As
Range)
Dim p As Object, t As Double, l As Double, w As Double, h As Double
If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
Set p = ActiveSheet.Pictures.Insert(PictureFileName)
With TargetCells
t = .Top
l = .Left
w = .Offset(0, .Columns.Count).Left - .Left
h = .Offset(.Rows.Count, 0).Top - .Top
End With
With p
.Top = t
.Left = l
.Width = w
.Height = h
End With
Set p = Nothing
End Sub