Quote:
Originally Posted by eduzs
"...LOCK PICK ME\" & "\" & Target.Value..." The problem maybe here, try:
|
Quote:
Originally Posted by eduzs
Try to remove the ".jpg"
|
Seems to me you two are just guessing...
Ivylodge: There seem to be some gaps in your code's logic. Try:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Shp As Shape, StrFldr As String
If Intersect(Target, [A:A]) Is Nothing Then Exit Sub
If Target.Row Mod 20 = 0 Then Exit Sub
For Each Shp In ActiveSheet.Shapes
With Shp
If .Type = msoPicture Then
If .TopLeftCell.Address = Target.Offset(0, 1).Address Then .Delete
End If
End With
Next
If Target.Value = "" Then Exit Sub
StrFldr = "C:\Users" & Environ("UserName") & "\Desktop\SKYPE\LOCK PICK ME\"
If Dir(StrFldr & Target.Value & ".jpg") = "" Then 'picture not there!
If MsgBox("Photo " & Target.Value & " Doesn't exist" & vbCrLf & "Open The Picture Folder ?", _
vbCritical + vbYesNo, "No Photo Found") = vbYes Then
With Application.Dialogs(xlDialogInsertPicture)
If .Show <> -1 Then
Set Shp = .SelectedItems(1)
Else
Exit Sub
End If
End With
Else
Exit Sub
End If
Else
Set Shp = ActiveSheet.Pictures.Insert(StrFldr & Target.Value & ".jpg")
End If
With Shp
.Top = Target.Offset(0, 1).Top + 5
.Left = Target.Offset(0, 1).Left + 5
.LockAspectRatio = msoFalse
.Height = Target.Offset(0, 1).Height - 10
.Width = Target.Offset(0, 1).Width - 10
End With
Target.Offset(1, 0).Select
End Sub
Note also that I've replaced your AND tests with nested IF tests; it's more efficient that way. I've also used Excel's own InsertPicture dialogue rather than the Shell object.