define DataMergePreference arrangeby and recordsperpage
nope0000 Jun 22, 2009 2:17 PMI 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#...

