Automatic numbering on dropevent

Started by frankp, December 03, 2013, 10:52:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

frankp

One more little question:

I see the code is counting all shapes in the document and i can't find the code to set
"allshapes" to only the shapes with "MyTestmaster" in the Master shape name.
Numbering is going wrong right now.

frankp


Jumpy

You need a line like the following somewhere in the code where you decide if the shape is based on the desired master.

If Left(shp.Master.Name, Len("MyTestmaster")) <> "MyTestmaster" Then Exit Function

frankp

Can't i just change this code?

Set allShapes = ActivePage.Shapes

It now marks all shapes in the document as "allShapes" but it should only mark the shapes with a
specific mastername as "allShapes".

The code you are mentioning, Jumpy, is already in this part of the code.

Function NeedsCounting(ByVal shp As IVShape) As Boolean

    NeedsCounting = False
    If shp.Master Is Nothing Then Exit Function
    If Left(shp.Master.Name, Len("Pagina")) <> "Pagina" Then Exit Function
    NeedsCounting = True

End Function


Jumpy

Quote from: frankp on February 20, 2014, 07:39:10 AM
Can't i just change this code?
Set allShapes = ActivePage.Shapes

It now marks all shapes in the document as "allShapes" but it should only mark the shapes with a
specific mastername as "allShapes".

No! The variable allShapes "is filled with" / "references now" the Shapes collection of the ActivePage-object.
There is nothing added or marked or selected!!!

You can now iterate through the shapes in that collection and if one of the shapes meets certain criteria, you can do sth. with the shape.


Perhaps what you want do do is select certain shapes?
In that case you have again to iterate through the collection of all shapes, and if a shapes meets the criteriy you add it to the a selection object:


Dim sel as Selection, shp as Shape
Set sel=ActiveWindow.Selection
sel.DeselectAll

For all shp in ActivePage.Shapes
  'If shp meets certain criteria, for example testes in your NeedsCounting function then do sth.
  If NeedsCounting(shp) then
    sel.Add shp
  End If
Next shp


frankp

Hi jumpy,
thanks for the answer but it's getting beyond my knowledge and understanding.
I think i'll leave it with this.

Thanks for the help everyone.