OK, I finally have time to mess with this thing.
I put in the lines that Peter so kindly posted here. There are a few things that I'm still not getting though.
in the first part of the suggestion I see that it runs through the document and finds the text box with my job number and labels it "jobnumber"
If I label the text box on the master page "jobnumber" before I import the data merge, that would probably do the trick, right?
The second part of the script I'm really just not getting.
Here's what I have (with the previous code still intact, just commented out.)
As always, Thanks a million!
//############################################################################
// # An InDesign CS3 JavaScript
// # Exports each page of an InDesign CS document as a separate PDF to
// # a selected folder using the current PDF export settings.
// ############################################################################
i //Display a choose folder dialog box.
if(app.documents.length != 0){
var myFolder = Folder.selectDialog (Choose a Folder);
if(myFolder != null){
myExportPages(myFolder);
}
}
else{
alert(Please open a document and try again.);
}
i //Find the textbox that contains the job number.
app.findTextPreferences = null;
app.findTextPreferences.findWhat = pnxx-^9^9^9^9;
f = app.activeDocument.findText();
for (i = 0; i < f.length; i++)
f.parentTextFrames[0].label = jobNumber;
function myExportPages(myFolder){
var myPageName, myFilePath, myFile;
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
var myDialog = app.dialogs.add();
with(myDialog.dialogColumns.add().dialogRows.add()){
staticTexts.add({staticLabel:Base name:});
var myBaseNameField = textEditboxes.add({editContents:myDocumentName, minWidth:160});
}
var myResult = myDialog.show({name:ExportPages});
if(myResult == true){
var myBaseName = myBaseNameField.editContents;
i //Remove the dialog box from memory.
myDialog.destroy();
i /* for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
i myPageName = myDocument.pages.item(myCounter).name;
i app.pdfExportPreferences.pageRange = myPageName;
i */
for (i = 0; i < myDocument.pages.length; i++)
{
jobnum = myDocument.pages.textFrames.item (jobNumber).contents;
i //The name of the exported files will be the base name + the page name + .pdf.
i //If the page name contains a colon (as it will if the document contains sections),
i //then remove the colon.
var myRegExp = new RegExp(:,gi);
myPageName = myPageName.replace(myRegExp, _);
i // myFilePath = myFolder + / + myBaseName + _ + myPageName + .pdf;
myFilePath = myFolder + / + myBaseName + _ + jobnum + .pdf;
myFile = new File(myFilePath);
myDocument.exportFile(ExportFormat.pdfType, myFile, false);
}
}
else{
myDialog.destroy();
}
}