View Single Post
 
Old 09-16-2018, 02:25 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by eduzs View Post
"...LOCK PICK ME\" & "\" & Target.Value..." The problem maybe here, try:
Quote:
Originally Posted by eduzs View Post
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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote