When running the code to identify if a picture/image exists in a cell, Excel keeps crashing and doesn't run the code even when I am running it step by step.
I've tried with shape.name, but same result. Can you guys think of a work around?. My Spreadsheet contains 530 rows, around 20% of them don't have pictures and I need to add one to every 'product' I apply the following loop from row = 2 to row = 530
I tried alternatives based on this page, but code keeps crashing: How to check whether any of shapes exists?
Dim rngCell As Range
Dim shp As Shape
Dim objPic As Picture
Dim Pic_bool As Boolean
Dim strFolder As String
Dim strFileName As String
Prod_name = Range("F" & i)
strFolder = "C:Documents/Pictures"
strFileName = strFolder & Prod_name & ".png"
Pic_bool = False
Set rngCell = Range("H" & i)
For Each shp In ActiveSheet.Shapes 'Excel crashes on this line
If shp.TopLeftCell.Address = rngCell.Address Then
If shp.Name = strFileName Then
Pic_bool = True
Exit For
End If
Next shp
If Pic_bool <> True Then
'Insert picture on Cell H&i
If Dir(strFileName) <> "" Then
Range("H" & i) = "No Picture Found"
End If
End If
Expected Result is every row in column H validates if a picture already exist, otherwise it inserts a picture