how can I recover deleted photo in worksheets with VBA code ?

wai yan

New Member
Joined
Apr 20, 2019
Messages
7
Sub Test()

Sheet6.Select
Sheet6.Range("E24:W204,AI1:BA204").Select
Call SelectAllPicturesInSelectedRange(Sheet6)

End Sub

Sub SelectAllPicturesInSelectedRange(ws As Worksheet)


Dim oShape As shape
Dim rUserSel As Range




If TypeName(Selection) <> "Range" Then Exit Sub

Set rUserSel = Selection

For Each oShape In ws.Shapes
If oShape.Type = msoPicture Then
If Not Intersect(oShape.TopLeftCell, rUserSel) Is Nothing Then
oShape.Select False
Selection.Delete

End If
End If
Next oShape

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
you can't.
VBA does not send data / images to the recycle bin, and there is no UNDO with VBA either!
You would need data recovery software.
 
Upvote 0

Forum statistics

Threads
1,216,587
Messages
6,131,586
Members
449,657
Latest member
Timber5

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top