12 Replies Latest reply on Apr 10, 2008 2:14 PM by (Robert_Tkaczyk)

    Grouping Help

      Hi,

      I am fairly new at this, and there seems to be very little information out there, or at least I don't know where to find it. I am trying to convert an application, written in Microsoft Access using VBA, from InDesign Version 2.0 to CS2 (and eventually CS3). The application was built by a past employee, who is no longer available.
      So far, I've made some progress, but I am currently stuck on creating a group.
      I don't understand the following:

      Function Add(GroupItems As Objects, [Layer], [At As idLocationOptions = idUnknown], [Reference]) As Group

      What I particulary don't understand is the [Reference].

      What does " Reference: Before/after this Group or at the beginning/end of this Document, Spread, Master Spread, Page or Layer as Document, Spread, MasterSpread, Page or Layer" mean?

      Here is some of my Code:

      Public Function AssembleDPM(ByRef myGroup As BatchInfo, myLabels() As PassInfo, myFiles() As PositionInfo)

      Dim docDPM As InDesign.Document
      Dim docFile As InDesign.Document
      Dim strFile As String
      Dim oPageItems As InDesign.PageItems
      Dim oPageItem As InDesign.PageItem
      Dim i As Byte
      Dim x As Long
      Dim oWindow As Variant
      Dim oSpread As InDesign.Spread
      Dim oLayer As InDesign.Layer
      Dim oGroups As Variant
      Dim oGroup As Variant
      Dim PageBounds()
      Dim xNudge As Double
      Dim yNudge As Double
      Dim oLabel As InDesign.TextFrame
      Dim WorkPath As String
      WorkPath = "G:\_Pre-Press\___Todays work\"

      If Len(myGroup.TemplateName) = 0 Then Exit Function

      Set docDPM = myIndesign.Open("C:\Program Files\ID Scripts\Grids\" & myGroup.TemplateName)

      i = 0

      Do While i <= UBound(myFiles)

      strFile = myFiles(i).JobFile

      Do While Len(Dir(WorkPath & strFile)) = 0
      If MsgBox(strFile & " Was not found.", vbYesNo + vbQuestion, "Try again?") = vbNo Then
      With myGroup
      If .ErrCount > 0 Then
      ReDim Preserve .ErrLog(.ErrCount)
      End If
      .ErrLog(.ErrCount) = strFile & " was not found." & docDPM.Name & " was aborted."
      .ErrCount = .ErrCount + 1
      GoTo ErrorCleanup
      End With
      End If
      Loop

      Set docFile = myIndesign.Open(WorkPath & strFile)

      docFile.Select Nothing

      For x = 1 To docFile.PageItems.Count
      docFile.Select docFile.PageItems.Item(x)
      DoEvents
      Next

      myIndesign.Copy

      myIndesign.ActiveDocument = docDPM

      Do

      docDPM.Select Nothing

      myIndesign.Paste
      DoEvents

      Set oWindow = myIndesign.ActiveWindow
      Set oSpread = oWindow.ActiveSpread
      Set oLayer = oWindow.ActiveLayer
      Set oGroups = oSpread.Groups
      Set oGroup = oGroups.Add(docDPM.Selection, oLayer, 1650945639, ??)

      The last line above, I can't get right.

      Thank-you in advance for any help. This probably won't be the last time I ask any questions.

      Thank-you,
      Christopher
      • 0. Re: Grouping Help
        Level 1
        each param in [xxx] you can ommit - it's optional :)

        Set oGroup = oGroups.Add(docDPM.Selection, oLayer)

        robin

        --
        www.adobescripts.com
        • 2. Re: Grouping Help
          Level 1
          Thank-you for your response.

          When I run it as you've said I get " Run-Time Error '30477': Invalid
          parameter

          I am assuming that must mean there is something wrong in the code elsewhere.


          ~Christopher

          -----Original Message-----
          From: Robert_Tkaczyk [mailto:member@adobeforums.com]
          Sent: Wednesday, April 09, 2008 4:43 PM
          To: adobe.scripting.indesign@adobeforums.com
          Subject: Re: Grouping Help

          A new message was posted by Robert_Tkaczyk in

          InDesign Scripting --
          Grouping Help

          each param in [xxx] you can ommit - it's optional :)

          Set oGroup = oGroups.Add(docDPM.Selection, oLayer)

          robin

          --
          www.adobescripts.com


          ------------------------------------------------------
          View/reply at
          Replies by email are OK.
          Use the unsubscribe form at
          to cancel
          your email subscription.
          • 3. Re: Grouping Help
            Level 1
            try:

            Set oGroup = oGroups.Add(Array(docDPM.Selection), oLayer)

            or

            Set oGroup = myIndesign.ActiveDocument.Groups.Add(docDPM.Selection)
            call oGroup.Move(oLayer)

            ... I always had problems when grouping selection ... so I move objects I want to group to new temporary layer and:

            Set myGroup = myPage.Groups.Add(myLayerTemp.PageItems.ItemByRange(1, -1))

            this will group all itmes on myLayerTemp

            '###############

            and one more thing - instead of:

            For x = 1 To docFile.PageItems.Count
            docFile.Select docFile.PageItems.Item(x)
            DoEvents
            Next

            you can write:

            call docFile.Select(docFile.PageItems.ItemByRange(1,-1))

            '###############

            and - if your procedure copy all objects from one-page document to another document and nothing more - you can write:

            [...]
            Set docFile = myIndesign.Open(WorkPath & strFile)
            ' ^^^^^ line from your code

            Set oGroup = docFile.Groups.Add(docFile.PageItems.ItemByRange(1, -1))
            oGroup.Label="qqqqq"
            ' temp label to find this object after pasting in docDPM document
            call myIndesign.Select(oGroup)
            ' select this group
            call myInDesign.Copy
            ' copy
            myIndesign.ActiveDocument = docDPM
            ' change active doc
            call myInDesign.Paste
            ' paste
            set oGroup = docDPM.Groups.Item("qqqqq")
            ' "find" group

            robin

            --
            www.adobescripts.com
            • 4. Re: Grouping Help
              Level 1
              Thank-you so much for your help. Here I thought I was the amateur, the way
              you wrote that code made much more sense then the way he did it. Not to
              mention the fact that nothing he did was commented.

              I am stuck again though.

              Set oGroup = docDPM.Groups.Item("qqqqq") 'This line is saying "The
              Requested Member of The Collection Does Not Exist", which is thereby not
              allowing the next line of code to run which is where it's actually crashing.

              PageBounds() = oGroup.VisibleBounds 'This Is Giving me an automation
              error that an object invoked has been disconnected



              The rest of my code is as follows.


              Set docFile = myIndesign.Open(WorkPath & strFile)

              Set oGroup = docFile.Groups.Add(docFile.PageItems.ItemByRange(1, -1))
              oGroup.Label = "qqqqq" ' temp label to find this object after pasting in
              docDPM document
              Call myIndesign.Select(oGroup) ' select this group
              Call myIndesign.Copy ' copy
              myIndesign.ActiveDocument = docDPM ' change active doc
              Call myIndesign.Paste ' paste
              Set oGroup = docDPM.Groups.Item("qqqqq") ' "find" group 'This is giving
              me a problem.


              Do

              PageBounds() = oGroup.VisibleBounds 'This Is Giving me my current
              problem
              xNudge = (PageBounds(3) - PageBounds(1)) / 2
              yNudge = (PageBounds(2) - PageBounds(0)) / 2

              oGroup.Move Array(-(xNudge) + myFiles(i).xOffset, -(yNudge) +
              myFiles(i).yOffset)

              Select Case myGroup.RotationID
              Case 2 'Head to Head
              If (CByte(myFiles(i).yOffset) / 2) Mod 2 = 0 Then
              oGroup.Rotate 180, idCenterAnchor
              End If
              Case 3 'Foot to Foot
              If (CByte(myFiles(i).yOffset) / 2) Mod 2 = 1 Then
              oGroup.Rotate 180, idCenterAnchor
              End If
              End Select

              oGroup.Ungroup
              DoEvents

              If i < UBound(myFiles) Then
              If myFiles(i + 1).JobFile = strFile Then
              i = i + 1
              GoTo NextDo
              End If
              End If

              strFile = Left(strFile, Len(strFile) - 4) & "eps"
              docFile.Export 1952400720, "C:\Thumbs\" & strFile, False
              DoEvents
              docFile.Close

              Exit Do
              NextDo:
              Loop

              If i = UBound(myFiles) Then
              Exit Do
              Else
              i = i + 1
              End If
              Loop

              GetInkInfo docDPM, myGroup, myLabels()

              PlaceLabels docDPM, myGroup, myLabels()

              docDPM.Save

              'If myGroup.ErrCount = 0 Then
              ' FilterInks docDPM, myGroup, myLabels()
              ' docDPM.Save
              'End If

              myGroup.Done = True

              ErrorCleanup:

              On Error Resume Next

              docDPM.Close

              End Function




              -----Original Message-----
              From: Robert_Tkaczyk [mailto:member@adobeforums.com]
              Sent: Wednesday, April 09, 2008 5:33 PM
              To: adobe.scripting.indesign@adobeforums.com
              Subject: Re: Grouping Help

              A new message was posted by Robert_Tkaczyk in

              InDesign Scripting --
              Grouping Help

              try:

              Set oGroup = oGroups.Add(Array(docDPM.Selection), oLayer)

              or

              Set oGroup = myIndesign.ActiveDocument.Groups.Add(docDPM.Selection)
              call oGroup.Move(oLayer)

              ... I always had problems when grouping selection ... so I move objects I
              want to group to new temporary layer and:

              Set myGroup = myPage.Groups.Add(myLayerTemp.PageItems.ItemByRange(1, -1))

              this will group all itmes on myLayerTemp

              '###############

              and one more thing - instead of:

              For x = 1 To docFile.PageItems.Count
              docFile.Select docFile.PageItems.Item(x)
              DoEvents
              Next

              you can write:

              call docFile.Select(docFile.PageItems.ItemByRange(1,-1))

              '###############

              and - if your procedure copy all objects from one-page document to another
              document and nothing more - you can write:

              [...]
              Set docFile = myIndesign.Open(WorkPath & strFile)
              ' ^^^^^ line from your code

              Set oGroup = docFile.Groups.Add(docFile.PageItems.ItemByRange(1, -1))
              oGroup.Label="qqqqq"
              ' temp label to find this object after pasting in docDPM document
              call myIndesign.Select(oGroup)
              ' select this group
              call myInDesign.Copy
              ' copy
              myIndesign.ActiveDocument = docDPM
              ' change active doc
              call myInDesign.Paste
              ' paste
              set oGroup = docDPM.Groups.Item("qqqqq")
              ' "find" group

              robin

              --
              www.adobescripts.com


              ------------------------------------------------------
              View/reply at
              Replies by email are OK.
              Use the unsubscribe form at
              to cancel
              your email subscription.
              • 5. Re: Grouping Help
                Level 1
                Set docFile = myIndesign.Open(WorkPath & strFile)

                Set oGroup = docFile.Groups.Add(docFile.PageItems.ItemByRange(1, -1))
                oGroup.Label = "qqqqq" ' temp label to find this object after pasting in
                docDPM document
                Call myIndesign.Select(oGroup) ' select this group
                Call myIndesign.Copy ' copy
                myIndesign.ActiveDocument = docDPM ' change active doc
                Call myIndesign.Paste ' paste

                ' ######################
                Set oGroup = docDPM.Groups.Item("qqqqq") ' "find" group 'This is giving
                me a problem.

                ' if you have error here - then there is problem with PASTE command in new document - docDPM ...
                ' ######################

                Do
                ' ######################
                PageBounds() = oGroup.VisibleBounds 'This Is Giving me my current
                problem
                ' can't be PageBounds() - delete "()"
                ' but this will be not PageBounds but Visible bounds of group
                ' ######################

                xNudge = (PageBounds(3) - PageBounds(1)) / 2
                yNudge = (PageBounds(2) - PageBounds(0)) / 2

                oGroup.Move Array(-(xNudge) + myFiles(i).xOffset, -(yNudge) +
                myFiles(i).yOffset)

                Select Case myGroup.RotationID
                Case 2 'Head to Head
                If (CByte(myFiles(i).yOffset) / 2) Mod 2 = 0 Then
                oGroup.Rotate 180, idCenterAnchor
                End If
                Case 3 'Foot to Foot
                If (CByte(myFiles(i).yOffset) / 2) Mod 2 = 1 Then
                oGroup.Rotate 180, idCenterAnchor
                End If
                End Select

                oGroup.Ungroup
                DoEvents

                If i < UBound(myFiles) Then
                If myFiles(i + 1).JobFile = strFile Then
                i = i + 1
                GoTo NextDo
                End If
                End If

                strFile = Left(strFile, Len(strFile) - 4) & "eps"
                docFile.Export 1952400720, "C:\Thumbs\" & strFile, False
                DoEvents
                ' ######################
                docFile.Close(1852776480)
                ' add (1852776480)
                ' this is idSaveOptions.idNo
                ' ######################

                Exit Do
                NextDo:
                Loop

                ' ######################
                If i = UBound(myFiles) Then
                Exit Do
                Else
                i = i + 1
                End If
                ' this IF could be shorter
                ' just
                If i = UBound(myFiles) Then
                Exit Do
                End If
                i = i + 1
                ' ######################

                Loop

                GetInkInfo docDPM, myGroup, myLabels()

                PlaceLabels docDPM, myGroup, myLabels()

                docDPM.Save

                'If myGroup.ErrCount = 0 Then
                ' FilterInks docDPM, myGroup, myLabels()
                ' docDPM.Save
                'End If

                myGroup.Done = True

                ErrorCleanup:

                On Error Resume Next

                ' ######################
                docDPM.Close(1852776480)
                ' add (1852776480)
                ' this is idSaveOptions.idNo
                ' ######################

                End Function


                ' ######################

                what your whole script should do ??

                robin

                --
                www.adobescripts.com
                • 6. Re: Grouping Help
                  Level 1
                  Robin,

                  The script is for assembling a press run from individual files containing
                  business cards. The script goes down a list (from Access), takes a file,
                  copies all of it's contents to a new file, pastes it to a specified
                  coordinate, and then it's supposed to open the next file in a list, copy
                  it's contents, and paste it to a new set of coordinates. I am not exactly
                  sure how he is getting the coordinates.
                  It works fine in InDesign 2.0, but I am trying to convert it to work with
                  CS2. (and eventually CS3)

                  I'll post the entire code assembly portion of the code. There is more code,
                  but I don't think it pertains to coding InDesign.

                  I feel like I'm close, I can get it to place one file where it needs to go
                  if I place "On Error Resume Next" before the " PageBounds() =
                  oGroup.VisibleBounds", but it doesn't seem to want to loop.


                  Option Compare Database
                  Option Explicit

                  Private Function myIndesign() As InDesign.Application
                  If myIndesign Is Nothing Then
                  Set myIndesign = CreateObject("Indesign.Application.cs2")
                  End If
                  End Function

                  Public Function AssembleDPM(ByRef myGroup As BatchInfo, myLabels() As
                  PassInfo, myFiles() As PositionInfo)

                  Dim docDPM As InDesign.Document
                  Dim docFile As InDesign.Document
                  Dim strFile As String
                  Dim oPageItems As InDesign.PageItems
                  Dim oPageItem As InDesign.PageItem
                  Dim i As Byte
                  Dim x As Long
                  Dim oWindow As InDesign.Window
                  Dim oSpread As InDesign.Spread
                  Dim oLayer As InDesign.Layer
                  Dim oGroups As InDesign.Groups
                  Dim oGroup As InDesign.Group
                  Dim PageBounds()
                  Dim xNudge As Double
                  Dim yNudge As Double
                  Dim oLabel As InDesign.TextFrame
                  Dim WorkPath As String
                  WorkPath = "G:\_Pre-Press\___Todays work\"

                  If Len(myGroup.TemplateName) = 0 Then Exit Function

                  Set docDPM = myIndesign.Open("C:\Program Files\ID Scripts\Grids\" &
                  myGroup.TemplateName)

                  Call docDPM.Save(WorkPath & myGroup.SavePath & myGroup.FileName, False)

                  'Call
                  myIndesign.ViewPreference.HorizontalMeasurementUnits(idMeasurementUnits.idIn
                  ches)
                  'Call
                  myIndesign.ViewPreference.VerticalMeasurementUnits(idMeasurementUnits.idInch
                  es)

                  i = 0

                  Do While i <= UBound(myFiles)

                  strFile = myFiles(i).JobFile

                  Do While Len(Dir(WorkPath & strFile)) = 0
                  If MsgBox(strFile & " Was not found.", vbYesNo + vbQuestion, "Try
                  again?") = vbNo Then
                  With myGroup
                  If .ErrCount > 0 Then
                  ReDim Preserve .ErrLog(.ErrCount)
                  End If
                  .ErrLog(.ErrCount) = strFile & " was not found." &
                  docDPM.Name & " was aborted."
                  .ErrCount = .ErrCount + 1
                  GoTo ErrorCleanup
                  End With
                  End If
                  Loop

                  Set docFile = myIndesign.Open(WorkPath & strFile)

                  Set oGroup = docFile.Groups.Add(docFile.PageItems.ItemByRange(1, -1))
                  oGroup.Label = "qqqqq" ' temp label to find this object after pasting in
                  docDPM document
                  Call myIndesign.Select(oGroup) ' select this group
                  Call myIndesign.Copy ' copy
                  myIndesign.ActiveDocument = docDPM ' change active doc
                  Call myIndesign.Paste ' paste
                  Set oGroup = docDPM.Groups.Item("qqqqq") ' "find" group


                  'docFile.Select Nothing

                  'For x = 1 To docFile.PageItems.Count
                  ' docFile.Select docFile.PageItems.Item(x), True
                  ' DoEvents
                  'Next

                  'myIndesign.Copy

                  'Set myIndesign.ActiveDocument = docDPM

                  Do

                  ' docDPM.Select Nothing
                  '
                  ' myIndesign.Paste
                  ' DoEvents

                  ' Set oWindow = myIndesign.ActiveWindow
                  ' Set oSpread = oWindow.ActiveSpread
                  ' Set oLayer = oWindow.ActiveLayer
                  ' Set oGroups = oSpread.Groups
                  ' Set oGroup = oGroups.Add(oLayer, docDPM.Selection)

                  ' On Error Resume Next
                  PageBounds() = oGroup.VisibleBounds
                  xNudge = (PageBounds(3) - PageBounds(1)) / 2
                  yNudge = (PageBounds(2) - PageBounds(0)) / 2

                  oGroup.Move Array(-(xNudge) + myFiles(i).xOffset, -(yNudge) +
                  myFiles(i).yOffset)

                  Select Case myGroup.RotationID
                  Case 2 'Head to Head
                  If (CByte(myFiles(i).yOffset) / 2) Mod 2 = 0 Then
                  oGroup.Rotate 180, idCenterAnchor
                  End If
                  Case 3 'Foot to Foot
                  If (CByte(myFiles(i).yOffset) / 2) Mod 2 = 1 Then
                  oGroup.Rotate 180, idCenterAnchor
                  End If
                  End Select

                  oGroup.Ungroup
                  DoEvents

                  If i < UBound(myFiles) Then
                  If myFiles(i + 1).JobFile = strFile Then
                  i = i + 1
                  GoTo NextDo
                  End If
                  End If

                  strFile = Left(strFile, Len(strFile) - 4) & "eps"
                  docFile.Export 1952400720, "C:\Thumbs\" & strFile, False
                  DoEvents
                  docFile.Close (idSaveOptions.idNo)

                  Exit Do
                  NextDo:
                  Loop

                  If i = UBound(myFiles) Then
                  Exit Do
                  Else
                  i = i + 1
                  End If
                  Loop

                  GetInkInfo docDPM, myGroup, myLabels()

                  PlaceLabels docDPM, myGroup, myLabels()

                  docDPM.Save

                  'If myGroup.ErrCount = 0 Then
                  ' FilterInks docDPM, myGroup, myLabels()
                  ' docDPM.Save
                  'End If

                  myGroup.Done = True

                  ErrorCleanup:

                  On Error Resume Next

                  docDPM.Close

                  End Function


                  Private Function PlaceLabels(ByRef docDPM As InDesign.Document, ByRef
                  myGroup As BatchInfo, ByRef myLabels() As PassInfo)

                  Dim y1, x1, y2, x2 As Double
                  Dim myMargin As Double
                  Dim xOffsets() As Double
                  Dim yOffset As Double
                  Dim i As Byte
                  Dim x As Byte
                  Dim n As Byte
                  Dim nSide As Byte
                  Dim bBack As Boolean
                  Dim myRuns() As String
                  Dim myCenter() As Double
                  Dim strDetails As String
                  Dim oLabel As InDesign.TextFrame
                  Dim oPoint As InDesign.InsertionPoint
                  Dim oColor As InDesign.Color

                  i = 0

                  Do While i <= UBound(myLabels)
                  x = 0
                  ReDim myRuns(x)
                  myRuns(x) = myLabels(i).RunName
                  nSide = myLabels(i).FilePosition

                  myCenter = GetOffsets(nSide, 1, myGroup.GroupTypeID, myGroup.GutterID,
                  False)
                  x1 = myCenter(0) - 1.75
                  x2 = myCenter(0) + 1.75
                  y1 = myCenter(1) - 1.372
                  y2 = myCenter(1) - 2

                  Set oLabel = docDPM.TextFrames.Add

                  oLabel.GeometricBounds = Array(y1, x1, y2, x2)
                  Do While nSide = myLabels(i).FilePosition
                  With myLabels(i)
                  If .RunName <> myRuns(x) Then
                  x = x + 1
                  ReDim Preserve myRuns(x)
                  myRuns(x) = .RunName
                  End If

                  If .Flat = True Then
                  strDetails = " FLAT"
                  Else
                  strDetails = ""
                  End If

                  If .TwoSided = True Then
                  If .Backside = True Then
                  strDetails = strDetails & " BACK"
                  Else
                  strDetails = strDetails & " FRONT"
                  End If
                  End If

                  If Len(.Alias) = 0 Then
                  strDetails = "RUN# " & .RunName & " - [PMS " & .JobInk & "]"
                  & strDetails
                  Else
                  strDetails = "RUN# " & .RunName & " - [" & .Alias & "]" &
                  strDetails
                  End If

                  Set oPoint =
                  oLabel.InsertionPoints.Item(oLabel.InsertionPoints.Count)

                  If .Swatch = 0 Then
                  Set oColor = docDPM.Swatches.Item("Registration")
                  If myGroup.ErrCount > 0 Then
                  ReDim Preserve myGroup.ErrLog(myGroup.ErrCount)
                  End If
                  myGroup.ErrLog(myGroup.ErrCount) = "The registration swatch
                  was used to color '" & strDetails & "'."
                  myGroup.ErrCount = myGroup.ErrCount + 1
                  Else
                  Set oColor = docDPM.Swatches.Item(.Swatch)
                  End If
                  End With

                  If i < UBound(myLabels) Then
                  If myLabels(i + 1).FilePosition = nSide Then
                  strDetails = strDetails & vbLf
                  End If
                  End If

                  oPoint.FillColor = oColor
                  oPoint.TextContents = strDetails

                  i = i + 1

                  If i > UBound(myLabels) Then
                  Exit Do
                  End If

                  Loop

                  Select Case myGroup.GroupTypeID
                  Case 1
                  bBack = myLabels(0).Backside
                  x = 2
                  Case 2
                  x = 0
                  Case Else
                  Exit Function
                  End Select

                  myMargin = 0

                  For n = 0 To x
                  myCenter() = GetOffsets(((n + 1) * nSide), 4, myGroup.GroupTypeID,
                  myGroup.GutterID, bBack)
                  ReDim Preserve xOffsets(n)
                  xOffsets(n) = myCenter(0)
                  If myMargin = 0 Or myMargin > (8.5 - (myCenter(1) + 2)) / 2 Then
                  myMargin = (8.5 - (myCenter(1) + 2)) / 2
                  yOffset = myCenter(1) + 1 + (myMargin / 2)
                  End If
                  Next

                  For n = 0 To x
                  x1 = xOffsets(n) - 1.75
                  x2 = xOffsets(n) + 1.75
                  y1 = yOffset - 0.03
                  y2 = yOffset + 0.03

                  strDetails = vbTab & Join(myRuns, "-") & vbTab
                  If myGroup.GroupTypeID = 1 Then
                  strDetails = strDetails & Chr(65 + n)
                  End If
                  If myGroup.GutterID > 1 Then
                  strDetails = strDetails & vbTab &
                  GetGutterName(myGroup.GutterID)
                  End If

                  Set oLabel = docDPM.TextFrames.Add
                  oLabel.GeometricBounds = Array(y1, x1, y2, x2)
                  Set oColor = docDPM.Swatches.Item("Registration")
                  Set oPoint = oLabel.InsertionPoints.Item(1)
                  oPoint.FillColor = oColor
                  oPoint.TextContents = strDetails
                  Next
                  Loop


                  End Function


                  Private Function GetInkInfo(ByRef docDPM As InDesign.Document, ByRef myGroup
                  As BatchInfo, ByRef myLabels() As PassInfo)

                  Dim i As Byte
                  Dim x As Long
                  Dim oSwatch As Object
                  Dim oColor As InDesign.Color
                  Dim oInk As InDesign.Ink

                  For x = 1 To docDPM.Inks.Count
                  Set oInk = docDPM.Inks.Item(x)
                  'If Len(oInk.AliasInkName) > 0 Then
                  'oInk.AliasInkName = "No Alias"
                  'End If
                  oInk.ConvertToProcess = False
                  Next

                  For Each oSwatch In docDPM.UnusedSwatches
                  If Len(oSwatch) > 0 Then
                  For x = 5 To docDPM.Swatches.Count
                  If docDPM.Swatches.Item(x) = oSwatch Then
                  docDPM.Swatches.Item(x).Delete docDPM.Swatches.Item("Black")
                  Exit For
                  End If
                  Next
                  Else
                  Exit For
                  End If
                  Next

                  For x = 1 To docDPM.Swatches.Count - 1
                  If TypeName(docDPM.Swatches.Item(x)) = "Color" Then
                  Set oColor = docDPM.Swatches.Item(x)
                  If oColor.Name <> "Paper" And oColor.Name <> "Registration" _
                  And InStr(docDPM.Swatches.Item(x), "PROOF") = 0 Then
                  If oColor.Model = oColor.Name = "Black" Then
                  For i = 0 To UBound(myLabels)
                  If InStr(oColor.Name, myLabels(i).JobInk) > 0 Then
                  If myLabels(i).Swatch = 0 Then
                  myLabels(i).Swatch = x
                  Else
                  If myGroup.ErrCount > 0 Then
                  ReDim Preserve
                  myGroup.ErrLog(myGroup.ErrCount)
                  End If
                  myGroup.ErrLog(myGroup.ErrCount) = "'" &
                  oColor.Name & "' should be replaced with '" &
                  docDPM.Swatches.Item(myLabels(i).Swatch) & "'."
                  myGroup.ErrCount = myGroup.ErrCount + 1
                  End If
                  End If
                  Next
                  End If
                  Else
                  If InStr(oColor.Name, "PROOF") > 0 Then
                  If myGroup.ErrCount > 0 Then
                  ReDim Preserve myGroup.ErrLog(myGroup.ErrCount)
                  End If
                  myGroup.ErrLog(myGroup.ErrCount) = docDPM.Swatches.Item(x) &
                  " must be manually removed."
                  myGroup.ErrCount = myGroup.ErrCount + 1
                  End If
                  End If
                  End If
                  Next


                  For x = 1 To docDPM.Inks.Count
                  Set oInk = docDPM.Inks.Item(x)
                  For i = 0 To UBound(myLabels)
                  If InStr(oInk.Name, myLabels(i).JobInk) > 0 Then
                  If myLabels(i).Ink = 0 Then
                  myLabels(i).Ink = x
                  Exit For
                  End If
                  End If
                  Next
                  Next

                  End Function



                  Private Function FilterInks(ByRef docDPM As InDesign.Document, ByRef myGroup
                  As BatchInfo, ByRef myLabels() As PassInfo)

                  Dim x As Byte
                  Dim oInk As InDesign.Ink

                  For x = 1 To docDPM.Inks.Count
                  MsgBox TypeName(docDPM.Inks.Item(x))
                  Set oInk = docDPM.Inks.Item(x)
                  oInk.PrintInk = False
                  Next

                  For x = 0 To UBound(myLabels)
                  With myLabels(x)
                  If .Ink > 0 Then
                  Set oInk = docDPM.Inks.Item(.Ink)
                  oInk.PrintInk = True
                  Else
                  If myGroup.ErrCount > 0 Then
                  ReDim Preserve myGroup.ErrLog(myGroup.ErrCount)
                  End If
                  myGroup.ErrLog(myGroup.ErrCount) = .JobInk & " is not
                  represented in the ink manager."
                  myGroup.ErrCount = myGroup.ErrCount + 1

                  End If
                  End With
                  Next

                  End Function


                  -----Original Message-----
                  From: Robert_Tkaczyk [mailto:member@adobeforums.com]
                  Sent: Thursday, April 10, 2008 11:08 AM
                  To: adobe.scripting.indesign@adobeforums.com
                  Subject: Re: Grouping Help

                  A new message was posted by Robert_Tkaczyk in

                  InDesign Scripting --
                  Grouping Help

                  Set docFile = myIndesign.Open(WorkPath & strFile)

                  Set oGroup = docFile.Groups.Add(docFile.PageItems.ItemByRange(1, -1))
                  oGroup.Label = "qqqqq" ' temp label to find this object after pasting in
                  docDPM document
                  Call myIndesign.Select(oGroup) ' select this group
                  Call myIndesign.Copy ' copy
                  myIndesign.ActiveDocument = docDPM ' change active doc
                  Call myIndesign.Paste ' paste

                  ' ######################
                  Set oGroup = docDPM.Groups.Item("qqqqq") ' "find" group 'This is giving
                  me a problem.

                  ' if you have error here - then there is problem with PASTE command in new
                  document - docDPM ...
                  ' ######################

                  Do
                  ' ######################
                  PageBounds() = oGroup.VisibleBounds 'This Is Giving me my current
                  problem
                  ' can't be PageBounds() - delete "()"
                  ' but this will be not PageBounds but Visible bounds of group
                  ' ######################

                  xNudge = (PageBounds(3) - PageBounds(1)) / 2
                  yNudge = (PageBounds(2) - PageBounds(0)) / 2

                  oGroup.Move Array(-(xNudge) + myFiles(i).xOffset, -(yNudge) +
                  myFiles(i).yOffset)

                  Select Case myGroup.RotationID
                  Case 2 'Head to Head
                  If (CByte(myFiles(i).yOffset) / 2) Mod 2 = 0 Then
                  oGroup.Rotate 180, idCenterAnchor
                  End If
                  Case 3 'Foot to Foot
                  If (CByte(myFiles(i).yOffset) / 2) Mod 2 = 1 Then
                  oGroup.Rotate 180, idCenterAnchor
                  End If
                  End Select

                  oGroup.Ungroup
                  DoEvents

                  If i < UBound(myFiles) Then
                  If myFiles(i + 1).JobFile = strFile Then
                  i = i + 1
                  GoTo NextDo
                  End If
                  End If

                  strFile = Left(strFile, Len(strFile) - 4) & "eps"
                  docFile.Export 1952400720, "C:\Thumbs\" & strFile, False
                  DoEvents
                  ' ######################
                  docFile.Close(1852776480)
                  ' add (1852776480)
                  ' this is idSaveOptions.idNo
                  ' ######################

                  Exit Do
                  NextDo:
                  Loop

                  ' ######################
                  If i = UBound(myFiles) Then
                  Exit Do
                  Else
                  i = i + 1
                  End If
                  ' this IF could be shorter
                  ' just
                  If i = UBound(myFiles) Then
                  Exit Do
                  End If
                  i = i + 1
                  ' ######################

                  Loop

                  GetInkInfo docDPM, myGroup, myLabels()

                  PlaceLabels docDPM, myGroup, myLabels()

                  docDPM.Save

                  'If myGroup.ErrCount = 0 Then
                  ' FilterInks docDPM, myGroup, myLabels()
                  ' docDPM.Save
                  'End If

                  myGroup.Done = True

                  ErrorCleanup:

                  On Error Resume Next

                  ' ######################
                  docDPM.Close(1852776480)
                  ' add (1852776480)
                  ' this is idSaveOptions.idNo
                  ' ######################

                  End Function


                  ' ######################

                  what your whole script should do ??

                  robin

                  --
                  www.adobescripts.com


                  ------------------------------------------------------
                  View/reply at
                  Replies by email are OK.
                  Use the unsubscribe form at
                  to cancel
                  your email subscription.
                  • 7. Re: Grouping Help
                    Larry G. Schneider Adobe Community Professional & MVP
                    Please turn off the Autoquote in your news reader.
                    • 8. Re: Grouping Help
                      Level 1
                      very strange way for me ...
                      better/faster/easier/etc. way is export each file as PDF and place PDF into destination file


                      you need to delete "()" after PageBounds

                      PageBounds = oGroup.VisibleBounds

                      robin

                      --
                      www.adobescripts.com
                      • 9. Re: Grouping Help
                        Level 1
                        Robin,

                        Thank-you for your help.

                        Unfortunately, at this point I don't have enough experience to re-write the scripts. I was hoping a conversion would be fairly simple, but it appears to be more complicated then that.

                        Taking the parenthesis out didn't work. I'll spend some more time playing with it.

                        ~Christopher
                        • 10. Re: Grouping Help
                          Level 1
                          Can I ask why it would be easier to export a .pdf, and then import .pdf files into the new file? Is this just because the coding would be easier to write?

                          Thanks
                          ~Christopher
                          • 11. Re: Grouping Help
                            Level 1
                            > Taking the parenthesis out didn't work. I'll spend some more time playing with it.

                            change:

                            Dim PageBounds()

                            to:

                            Dim PageBounds as Variant

                            robin

                            --
                            www.adobescripts.com
                            • 12. Re: Grouping Help
                              Level 1
                              > Can I ask why it would be easier to export a .pdf, and then import .pdf files into the new file? Is this just because the coding would be easier to write?

                              because when you copy/paste objects - you will lose everything what is in background - on MasterPage(s)
                              and when you copy/paste - something can go wrong - your layout can change, text can reflow, etc.
                              you will be in big trouble if you don't have linked graphic or font used in indd file installed on your computer

                              when you make PDF and place it in another document - everything remain intact
                              you can include all fonts, all graphics and assign color profile, you can use this PDF on other version of ID, on other end of world ;)

                              if each source doc have different size - you still need to place each object individually - but you don't need to play with group of objects, you can turn on bleeds and you have one more advantage - you can export your source document again and only refresh linked PDF - you don't need to build whole doc from scratch

                              robin

                              --
                              www.adobescripts.com