Cook09
asked on
Why doesn't "i" Work with Pictures
I have a worksheet that has several "Pictures" or, Picture objects, on it that I would like to remove.
In running the Macro Recorder, it lists these objects as ActiveSheet.Shapes("Pictur e #") or
That doesn't work though, it doesn't recognize the "i". However, If I replace the i with a 1, then it will work. I have tried changing i to Long, String, etc. Even though i = 1 is the right value, the code won't allow it to excecute, it has to be the actual number. Why is this? It defeats the whole purpose for variables.
In running the Macro Recorder, it lists these objects as ActiveSheet.Shapes("Pictur
ActiveSheet.Shapes("Picture 1").Select
In putting together some code to delete these I used - This is the short version to my question:Sub DeleteShapes()
Dim shp As Shape, i As integer
i = 1
For Each shp In ActiveSheet.Shapes
ActiveSheet.Shapes("Picture [b]i[/b]").Delete
i = i + 1
Next
i = 0
End Sub
That doesn't work though, it doesn't recognize the "i". However, If I replace the i with a 1, then it will work. I have tried changing i to Long, String, etc. Even though i = 1 is the right value, the code won't allow it to excecute, it has to be the actual number. Why is this? It defeats the whole purpose for variables.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think I may have figured out the error, there are some Merged Cells and it may have errored out on those. That's the thought anyway.
ASKER