Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking

    Hello
    I use the code below to insert a picture/photo into a selected cell that has protection
    Code:
    Dim sFile As Variant, r As Range
      Set r = Range("AL1")
      sFile = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp), *.jpg;*.bmp", Title:="Browse to select a picture")
      If sFile = False Then Exit Sub
      ActiveSheet.Unprotect
      With ActiveSheet.Pictures.Insert(sFile).ShapeRange
    	.LockAspectRatio = True
    	.Top = r.Top
    	.Left = r.Left
    	.Height = r.RowHeight * r.MergeArea.Rows.Count
      End With
      ActiveSheet.Protect
    Is it possible to delete old picture before inserting new picture, so they dont keep piling up on one another

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could use code like this (before inserting the new picture!):

    Code:
      Dim i As Long
      For i = ActiveSheet.Pictures.Count To 1 Step -1
    	If ActiveSheet.Pictures(i).Top = r.Top And _
    		ActiveSheet.Pictures(i).Left = r.Left Then
    	  ActiveSheet.Pictures(i).Delete
    	End If
      Next i

  3. #3
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi HansV
    Thats works FANTASIC
    Thank you so much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •