1 Reply Latest reply on Jun 22, 2009 4:00 PM by nope0000

    define DataMergePreference arrangeby and recordsperpage

    nope0000 Level 1

      I try to merge data from a csv file in InDesign CS3 with vbscript. the first script below works fine, but how can i arrange multiple records by columns or rows per page? Setting DataMergePreference.ArrangeBy and DataMergePreference.RecordsPerPage just won't work.

       

      merging with ID default settings (one record per page) works fine with this code:

       

      set arg = WScript.Arguments

      idYes = 2036691744
      idNo = 1852776480
      idNeverInteract = 1699640946
      idInteractWithAll = 1699311169
      idColumnsFirst = 1684882278
      idMultipleRecord = 1684884850

       

      Set myInDesignApplication = CreateObject("InDesign.Application.CS3")

      Set myDocument = myInDesignApplication.Open(arg(0),True)

      Set myDataProperties = myDocument.DataMergeProperties

      myInDesignApplication.scriptPreferences.userInteractionLevel = idNeverInteract

      myDataProperties.SelectDataSource(arg(1))

      myDataProperties.MergeRecords()

       

      myDocument.Close idNo

       

      myInDesignApplication.findTextPreferences.findWhat = "\r\n"               rem works in cs3
      myInDesignApplication.changeTextPreferences.changeTo = "^p"          rem works in cs3
      myInDesignApplication.ActiveDocument.changeText                           rem works in cs3

      myInDesignApplication.ActiveDocument.Close idYes, arg(2)

       

      If myInDesignApplication.Documents.Count < 1 Then

      myInDesignApplication.Quit

      Else

      myInDesignApplication.scriptPreferences.userInteractionLevel = idInteractWithAll
      End If

       

       

      merging multiple records by coumn with something like the following doesn't work:

       

      set arg = WScript.Arguments

      idYes = 2036691744
      idNo = 1852776480
      idNeverInteract = 1699640946
      idInteractWithAll = 1699311169
      idColumnsFirst = 1684882278
      idMultipleRecord = 1684884850

       

      Set myInDesignApplication = CreateObject("InDesign.Application.CS3")

      Set myDocument = myInDesignApplication.Open(arg(0),True)

      Set myDataProperties = myDocument.DataMergeProperties

      myInDesignApplication.scriptPreferences.userInteractionLevel = idNeverInteract

      myDataProperties.SelectDataSource(arg(1))

      myDataProperties.RecordsPerPage = idMultipleRecord
      myDataProperties.ArrangeBy = idColumnsFirst

      myDataProperties.MergeRecords()

       

      myDocument.Close idNo

       

      myInDesignApplication.findTextPreferences.findWhat = "\r\n"
      myInDesignApplication.changeTextPreferences.changeTo = "^p"
      myInDesignApplication.ActiveDocument.changeText

      myInDesignApplication.ActiveDocument.Close idYes, arg(2)

       

      If myInDesignApplication.Documents.Count < 1 Then

      myInDesignApplication.Quit

      Else

      myInDesignApplication.scriptPreferences.userInteractionLevel = idInteractWithAll
      End If

       

       

       

      I tried everything to set RecordsPerPage and ArrangeBy, nothing worked:

       

      myInDesignApplication.RecordsPerPage = idMultipleRecord
      myInDesignApplication.ArrangeBy = idColumnsFirst

       

      nor

       

      myDocument.DataMergePreference.RecordsPerPage

      myDocument.DataMergePreference.ArrangeBy

       

      myDocument.DataMerge.DataMergePreference.RecordsPerPage

      myDocument.DataMerge.DataMergePreference.ArrangeBy

       

      myDocument.DataMerge.DataMergePreferences.RecordsPerPage

      myDocument.DataMerge.DataMergePreferences.ArrangeBy

       

      followed by = idMultipleRecord/idColumnsFirst or (idMultipleRecord/idColumnsFirst).

       

      What am i doing wrong?

       

      Would be great if anyone can tell me how to use Indesign Library's "idXXXXX" the right way (without defining variables like i did)

       

      Never had problems like this when coding in c, c++ or c#...

        • 1. Re: define DataMergePreference arrangeby and recordsperpage
          nope0000 Level 1

          To merge multiple records per page arranged by collumn in VBScript do something like

           

          Set myInDesignApplication = CreateObject("InDesign.Application.CS3")

          Set myDocument = myInDesignApplication.Open(c:\not_dev_null\document.indd,True)

          Set myDataProperties = myDocument.DataMergeProperties

          myDataProperties.SelectDataSource(c:\not_dev_null\data.csv)

          myDataProperties.DatamergePreferences.RecordsPerPage = idMultipleRecord
          myDataProperties.DatamergePreferences.ArrangeBy = idColumnsFirst

          myDataProperties.MergeRecords()

           

           

          DatamergePreferences is Member of InDesign.DataMerge, that is Interface to Property like i.e. InDesign.Document.DatamergeProperties.