I have the following code that has been working for about a year now and all of the sudden it keeps debugging and saying Run Time Error '1004': Select method of Picture Class failed.
Here is a piece of the code:
The Names, properties, cell links are all valid and remain unchanged. All the pictures it is inserting are .jpg, so why this error message?
Thanks for your help in advance.
Here is a piece of the code:
Code:
For Each Sheet In Worksheets
Sheet.Activate
For Each Pic In ActiveSheet.Pictures
Pic.Delete
Next Pic
Next Sheet
Sheets("Sheet1").Select
Dim picnme As String
Dim rng As Range
Dim i, j As Integer
Dim Count As Integer
Count = 0
For i = 6 To 106
j = i + 1
'The count variable will be used to decide whether to perform the actions.
'It is set up to match your specified pattern.
Count = Count + 1
If Count > 8 Then Count = 1
If Count < 6 Then
'rows 6-10
picnme = Range("U" & i)
Range("C" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
picnme = Range("U" & i)
Range("C" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
picnme = Range("U" & i)
Range("C" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
picnme = Range("U" & i)
Range("C" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
picnme = Range("U" & i)
Range("C" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
picnme = Range("V" & i)
Range("G" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
picnme = Range("V" & i)
Range("G" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
picnme = Range("V" & i)
Range("G" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
picnme = Range("V" & i)
Range("G" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
picnme = Range("V" & i)
Range("G" & j).Select
ActiveSheet.Pictures.Insert( _
"C:\Archive\Pictures\" & picnme & ".jpg").Select
Selection.ShapeRange.IncrementTop -21#
Selection.ShapeRange.ScaleHeight 0.62, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.72, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.03, msoFalse, msoScaleFromTopLeft
The Names, properties, cell links are all valid and remain unchanged. All the pictures it is inserting are .jpg, so why this error message?
Thanks for your help in advance.