6 Replies Latest reply on Nov 13, 2008 9:48 AM by Dave Pepper

    Problem Grouping Objects vb cs2

    Dave Pepper Level 1
      I'm trying to group three objects but receive an error that says "Invalid value for parameter 'GroupItems' of event 'Add'. Expected PageItems but received (Rectangle, TextFrame, PDF)." It seems that the Groups.Add method is receiving the typename of my objects and not the objects themselves. I can't figure out why.

      This is especialy curious because I can manipulate my objects when they are put in the array (e.g. I can change properties of the objects, etc). Below is an abridged version of my code.

      Sub GroupItems()
      Dim MyInDesign
      Dim MyPage
      Dim MySelection
      Dim MySymbol
      Dim MyBlock
      Dim MyGroup, MyGroupArray(2)

      Set MyInDesign = CreateObject("InDesign.Application.Cs2")
      Set MyPage = MyInDesign.ActiveWindow.ActivePage

      Set MySelection = MyInDesign.Selection.Item(1)
      Set MyBlock = MyPage.Rectangles.Add
      Set MySymbol = MyPage.Place("T:\eLearning\numbers\Summary Box Symbols\something.ai")

      Set MyGroupArray(0) = MyBlock
      Set MyGroupArray(1) = MySelection.Parent
      Set MyGroupArray(2) = MySymbol
      Set MyGroup = MyDoc.Groups.Add(MyGroupArray)
      End Sub