I have been trying to get a picture to upload from a directory (listed in cell E8) and to resize itself to fit into a merged cell I made (cell J10... which takes up J10:R20). I want this to check the directory and if it has changed, re-upload the new image in the directory listed in that cell.
I came up with this macro which worked for a while...
Sub Pic1()
Dim Loc As String
Loc = Range("E8").Text
ActiveSheet.Pictures.Insert (Loc)
With ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
.LockAspectRatio = False
.Top = Range("J10:R20").Top
.Left = Range("J10:R20").Left
.Height = Range("J10:R20").Height
.Width = Range("J10:R20").Width
End With
End Sub
Sub Reload()
Dim pic As Picture
For Each pic In ActiveSheet.Pictures
If pic.Name <> "Picture 1" Then
pic.Delete
End If
Next pic
Pic1
Pic2
Pic3
Pic4
End Sub
But when I changed the directory to a new directory, it stopped working with 400 error flashing up every time I run it.
Any ideas?
Thanks in Advance.
I came up with this macro which worked for a while...
Sub Pic1()
Dim Loc As String
Loc = Range("E8").Text
ActiveSheet.Pictures.Insert (Loc)
With ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
.LockAspectRatio = False
.Top = Range("J10:R20").Top
.Left = Range("J10:R20").Left
.Height = Range("J10:R20").Height
.Width = Range("J10:R20").Width
End With
End Sub
Sub Reload()
Dim pic As Picture
For Each pic In ActiveSheet.Pictures
If pic.Name <> "Picture 1" Then
pic.Delete
End If
Next pic
Pic1
Pic2
Pic3
Pic4
End Sub
But when I changed the directory to a new directory, it stopped working with 400 error flashing up every time I run it.
Any ideas?
Thanks in Advance.
Last edited: