PC Review


Reply
Thread Tools Rate Thread

Delete Unlocked Pictures from Sheet1 with Code

 
 
Corey
Guest
Posts: n/a
 
      30th Jul 2007
The below code is being used to remove any values from all cells that are not locked.

But i want to add a line to delete ALL pictures in the same sheet (Sheet1 = Layout Sheet) that are
also NOT LOCKED.

I have some logo's on the sheet that i have LOCKED, so i do NOT want these deleted.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub Button72_Click()
Application.DisplayAlerts = False
' Delete Unlocked Pictures code here
'
'
' Then clear cell contents that are Unlocked
With Sheet1
..Select
..Unprotect
Dim c As Range
For Each c In Sheets("Layout Sheet").UsedRange
If c.Locked = False Then
c.Value = ""
End If
Next
..Protect
End With
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Can anyone help?

Corey....


 
Reply With Quote
 
 
 
 
Corey
Guest
Posts: n/a
 
      30th Jul 2007
Got it.

Used:

Sub Remove_Images()
Application.ScreenUpdating = False
Sheet1.Select
Dim DrObj
Dim Pict
Set DrObj = ActiveSheet.DrawingObjects
For Each Pict In DrObj
If Pict.Locked = False Then
Pict.Select
Pict.Delete
End If
Next
Application.ScreenUpdating = True
End Sub


"Corey" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
The below code is being used to remove any values from all cells that are not locked.

But i want to add a line to delete ALL pictures in the same sheet (Sheet1 = Layout Sheet) that are
also NOT LOCKED.

I have some logo's on the sheet that i have LOCKED, so i do NOT want these deleted.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub Button72_Click()
Application.DisplayAlerts = False
' Delete Unlocked Pictures code here
'
'
' Then clear cell contents that are Unlocked
With Sheet1
..Select
..Unprotect
Dim c As Range
For Each c In Sheets("Layout Sheet").UsedRange
If c.Locked = False Then
c.Value = ""
End If
Next
..Protect
End With
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Can anyone help?

Corey....



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      30th Jul 2007
If you only want to delete unlocked pictures try -

Dim pic As Picture
For Each pic In ActiveSheet.Pictures
If Not pic.Locked Then
pic.Delete
End If
Next

Note typically objects, such as inserted pictures, are locked by default.

Regards,
Peter T

"Corey" <(E-Mail Removed)> wrote in message
news:erMZD$(E-Mail Removed)...
> Got it.
>
> Used:
>
> Sub Remove_Images()
> Application.ScreenUpdating = False
> Sheet1.Select
> Dim DrObj
> Dim Pict
> Set DrObj = ActiveSheet.DrawingObjects
> For Each Pict In DrObj
> If Pict.Locked = False Then
> Pict.Select
> Pict.Delete
> End If
> Next
> Application.ScreenUpdating = True
> End Sub
>
>
> "Corey" <(E-Mail Removed)> wrote in message

news:(E-Mail Removed)...
> The below code is being used to remove any values from all cells that are

not locked.
>
> But i want to add a line to delete ALL pictures in the same sheet (Sheet1

= Layout Sheet) that are
> also NOT LOCKED.
>
> I have some logo's on the sheet that i have LOCKED, so i do NOT want these

deleted.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Sub Button72_Click()
> Application.DisplayAlerts = False
> ' Delete Unlocked Pictures code here
> '
> '
> ' Then clear cell contents that are Unlocked
> With Sheet1
> .Select
> .Unprotect
> Dim c As Range
> For Each c In Sheets("Layout Sheet").UsedRange
> If c.Locked = False Then
> c.Value = ""
> End If
> Next
> .Protect
> End With
> ActiveWorkbook.Save
> ActiveWorkbook.Close
> Application.DisplayAlerts = True
> End Sub
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Can anyone help?
>
> Corey....
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete the content of all unlocked cells in a protected she DrDisk7 Microsoft Excel Misc 1 8th Jan 2008 09:58 AM
Delete contents unlocked cells RobN Microsoft Excel Misc 9 13th Dec 2007 10:34 PM
Does this code Delete pictures or simply makes them Invisible Corey Microsoft Excel Programming 2 10th Aug 2007 12:34 AM
Delete contents of unlocked cells in another worksheet =?Utf-8?B?S0ZFYWdsZQ==?= Microsoft Excel Misc 3 9th Aug 2005 08:42 PM
Code to colour Unlocked cells Stuart Microsoft Excel Programming 7 1st Jun 2004 07:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:10 PM.