SerenityNetworks
Board Regular
- Joined
- Aug 13, 2009
- Messages
- 131
- Office Version
- 365
- Platform
- Windows
I'm using a VBA macro to load 15 pictures in various positions in an Excel worksheet. I'll examine those pictures, delete them, then load some more. The process repeats hundreds of times. This works fine if I want to delete all the pictures that I load. However, I'd like to add some shapes that I don't want deleted. I'd also like to add a 16th picture that I don't want deleted. I'm at a loss as to how to do this (I can manage working with VBA, but I'm not a coder.)
Right now, I'm loading each picture using the following code.
As you can see, I've tried naming the picture so I can delete it by name. But if this is the suggested method for deleting specific pictures then please help me with the syntax I need to do it. I've not been able to figure it out.
The following code works fine to delete all pictures, but as I mentioned, my goal is to only delete 15 of the pictures (not the 16th picture or shape I've added to the worksheet.
Any help on this will be appreciated.
Thanks,
Andrew
Right now, I'm loading each picture using the following code.
Code:
Sub Image15()
Dim objPicture As Picture
With Sheet4.Cells(1, 1) ' Picture displays in cell from row, column
Set objPicture = .Parent.Pictures.Insert(Sheet4.Cells(2, 51).Value) ' Picture path row, column
objPicture.Top = gvarImage15Top
objPicture.Left = gvarImage15Left
objPicture.Width = gvarImage15Width
objPicture.name = "pic15" ' Trying to see if I can delete by name
End With
End Sub
As you can see, I've tried naming the picture so I can delete it by name. But if this is the suggested method for deleting specific pictures then please help me with the syntax I need to do it. I've not been able to figure it out.
The following code works fine to delete all pictures, but as I mentioned, my goal is to only delete 15 of the pictures (not the 16th picture or shape I've added to the worksheet.
Code:
Sub DeleteImages()
Dim shape As Excel.shape
For Each shape In ActiveSheet.Shapes
shape.Delete
'Next
End Sub
Any help on this will be appreciated.
Thanks,
Andrew