Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Deleting images in Excel document

Here's my dilemma: I have a worksheet which on the click of 'Command
Button1' unprotects the worksheet, inserts a desired image into a
group of merged cells identified as cell L43 and then reprotects the
worksheet. I then have a second command button (Command Button2) that
when clicked unprotects the worksheet, removes the image from this
same group of cells and then reprotects the worksheet. Unfortunately,
when I click this Command2 button, it not only removes the image in
cell L43, it also removes every other image in the worksheet. I only
want the images in cell L43 to be removed. Any help would be
appreciated! Here's the Command2 button code:


Private Sub CommandButton2_Click()

Application.ActiveSheet.Unprotect "password"

For Each Picture In Pictures

'ActiveSheet.Pictures.Delete
'Debug.Print Picture.Name

If Left(Picture.Name, 7) = "Picture" Then

Picture.Delete

End If

Next

Application.ActiveSheet.Protect "password"

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Deleting images in Excel document

Pictures are not "in cell", so the easiest way is to use the shapes name.
You can set this when you insert the picture.
If you have other control on the WS that you wish to keep, check what the
shape is before deleting.

Private Sub CommandButton1_Click()
ActiveSheet.Shapes("PicToDelete").Delete
End Sub

NickHK

wrote in message
oups.com...
Here's my dilemma: I have a worksheet which on the click of 'Command
Button1' unprotects the worksheet, inserts a desired image into a
group of merged cells identified as cell L43 and then reprotects the
worksheet. I then have a second command button (Command Button2) that
when clicked unprotects the worksheet, removes the image from this
same group of cells and then reprotects the worksheet. Unfortunately,
when I click this Command2 button, it not only removes the image in
cell L43, it also removes every other image in the worksheet. I only
want the images in cell L43 to be removed. Any help would be
appreciated! Here's the Command2 button code:


Private Sub CommandButton2_Click()

Application.ActiveSheet.Unprotect "password"

For Each Picture In Pictures

'ActiveSheet.Pictures.Delete
'Debug.Print Picture.Name

If Left(Picture.Name, 7) = "Picture" Then

Picture.Delete

End If

Next

Application.ActiveSheet.Protect "password"

End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
When reopening document, images move BWill Excel Discussion (Misc queries) 1 December 17th 09 07:19 PM
script for deleting images Gor_yee Excel Discussion (Misc queries) 2 October 29th 07 12:38 PM
Deleting Multiple Images A.S. Excel Discussion (Misc queries) 3 August 19th 06 03:18 PM
some images in excel document print inversed JohnnieV Excel Discussion (Misc queries) 0 January 13th 05 02:27 AM
Find images in a Excel document.. How !! LNHockey Excel Programming 1 February 10th 04 05:00 PM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"