We help IT Professionals succeed at work.
Get Started

Why doesn't "i" Work with Pictures

Last Modified: 2012-08-16
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("Picture #") or
ActiveSheet.Shapes("Picture 1").Select

Open in new window

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
i = 0
End Sub

Open in new window

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.
Watch Question
Top Expert 2008
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE