M
Michael Pollard
I have a "For Each" loop that gets most of the items the first time around,
and the rest the second time. It takes two loops to get everything. ("Each"
doesn't get each "each".)
Each object has a custom property that potentially refers to another object
by ID; if that other object is there, I want to delete it. The objects missed
are almost consistent; they are consistent if the selection is the same, but
some items appear to vary depending on the other selected items. Just for
confirmation, nothing is going on between the two loops; I just click Play in
the Editor each time. And I have 2003 Pro.
Please let me know if you see a logic error in the function. (I may have
made a "stupid" mistake...) Also, feel free to let me know if there is a
better way of doing it.
My code:
Public Function DeleteAllBackgroundBoxes()
Dim CurrentObject As Object
' Loop through all objects
For Each CurrentObject In Application.ActivePage.Shapes
' Determine if the background ID property exists
If CurrentObject.CellExistsU("Prop.BackgroundObjectID", False) Then
If Not
((CurrentObject.CellsU("Prop.BackgroundObjectID").FormulaU = "") Or _
(CurrentObject.CellsU("Prop.BackgroundObjectID").FormulaU =
0)) Then
' If so, delete the background and the background ID
ActivePage.Shapes.ItemFromID(CurrentObject.CellsU("Prop.BackgroundObjectID")).Delete
CurrentObject.CellsU("Prop.BackgroundObjectID").FormulaU = ""
End If
End If
Next
End Function
and the rest the second time. It takes two loops to get everything. ("Each"
doesn't get each "each".)
Each object has a custom property that potentially refers to another object
by ID; if that other object is there, I want to delete it. The objects missed
are almost consistent; they are consistent if the selection is the same, but
some items appear to vary depending on the other selected items. Just for
confirmation, nothing is going on between the two loops; I just click Play in
the Editor each time. And I have 2003 Pro.
Please let me know if you see a logic error in the function. (I may have
made a "stupid" mistake...) Also, feel free to let me know if there is a
better way of doing it.
My code:
Public Function DeleteAllBackgroundBoxes()
Dim CurrentObject As Object
' Loop through all objects
For Each CurrentObject In Application.ActivePage.Shapes
' Determine if the background ID property exists
If CurrentObject.CellExistsU("Prop.BackgroundObjectID", False) Then
If Not
((CurrentObject.CellsU("Prop.BackgroundObjectID").FormulaU = "") Or _
(CurrentObject.CellsU("Prop.BackgroundObjectID").FormulaU =
0)) Then
' If so, delete the background and the background ID
ActivePage.Shapes.ItemFromID(CurrentObject.CellsU("Prop.BackgroundObjectID")).Delete
CurrentObject.CellsU("Prop.BackgroundObjectID").FormulaU = ""
End If
End If
Next
End Function