Hello, I have decided to ask for some help here after not being able to figure this one out. the following is a small portion of code trying to isolate the problem. I have a shaperange with 4 guidelines, after adding the 4 guidelines to the shapeange I delete the last one but the count of the shaperange remains in 4 instead of 3. What could be wrong here:
Sub InitialGuidesTest()
Dim Xleft As Double Dim Xright As Double Dim Ytop As Double Dim Ybottom As Double Dim C As Integer Dim OutterGuidelines As New ShapeRange OutterGuidelines.Delete Xleft = 5 Xright = 10 Ytop = 10 Ybottom = 5 ' Create new guides OutterGuidelines.Add ActiveLayer.CreateGuide(ActivePage.LeftX, Ybottom, ActivePage.RightX, Ybottom) ' Hor OutterGuidelines.Add ActiveLayer.CreateGuide(ActivePage.LeftX, Ytop, ActivePage.RightX, Ytop) ' Hor OutterGuidelines.Add ActiveLayer.CreateGuide(Xleft, ActivePage.TopY, Xleft, ActivePage.BottomY) ' Vert OutterGuidelines.Add ActiveLayer.CreateGuide(Xright, ActivePage.TopY, Xright, ActivePage.BottomY) ' Vert OutterGuidelines(4).Delete ' Delete the fourth guide C = OutterGuidelines.Count ' Get the count of guides MsgBox C ' Display the count '(Still displays 4 instead of 3)End Sub
That's not how it works, although it wouldn't be very difficult to execute a loop in a shaperange, it turns out that the position will still be occupied but with an empty reference, if you try to access it you will receive an exception.
you need to remove the shape from the range
OutterGuidelines(4).Delete
OutterGuidelines.Remove(4)
Thanks a lot. !