D
Dave Unger
Hello everyone,
I’ve tried searching the various groups, but I haven’t come across
anything that quite addresses this.
I have the following code, dummied down from a large application.
Basically, running the code with Sheet1 active, deleting a shape(s)
from Sheet2.
Sub deleteShape()
Dim Shp As Shape
Sheet1.Protect , True, True, True, True
Sheet2.Protect , True, True, True, True
' Sheet1.Protect , False
Sheet2.Protect , False
For Each Shp In Sheet2.Shapes
Shp.Delete
Next Shp
End Sub
As it stands, the code works as expected with xl2007. However, it
will kick out a 1004 error running under xl2000 or 2003 at the
Shp.Delete line. I can get it to work by either uncommenting the line
“Sheet1.Protect, False”, or, by keeping Sheet2 active. Also runs ok
if Sheet3 is active (unprotected sheet). In other words, it seems as
if the active sheet has to be unprotected, in addition to sheet2.
If someone could confirm that this is correct, I would be most
obliged. I ran into this at the last minute, (application developed
in xl2007), expected to do a few quick tests with xl2003 and be done
with it. Well, 3 hours later . . .;-)
Regards,
DaveU
I’ve tried searching the various groups, but I haven’t come across
anything that quite addresses this.
I have the following code, dummied down from a large application.
Basically, running the code with Sheet1 active, deleting a shape(s)
from Sheet2.
Sub deleteShape()
Dim Shp As Shape
Sheet1.Protect , True, True, True, True
Sheet2.Protect , True, True, True, True
' Sheet1.Protect , False
Sheet2.Protect , False
For Each Shp In Sheet2.Shapes
Shp.Delete
Next Shp
End Sub
As it stands, the code works as expected with xl2007. However, it
will kick out a 1004 error running under xl2000 or 2003 at the
Shp.Delete line. I can get it to work by either uncommenting the line
“Sheet1.Protect, False”, or, by keeping Sheet2 active. Also runs ok
if Sheet3 is active (unprotected sheet). In other words, it seems as
if the active sheet has to be unprotected, in addition to sheet2.
If someone could confirm that this is correct, I would be most
obliged. I ran into this at the last minute, (application developed
in xl2007), expected to do a few quick tests with xl2003 and be done
with it. Well, 3 hours later . . .;-)
Regards,
DaveU