🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #1897

Re: [CS4 JavaScript] Adding a CrossReferenceFormat

#1897
From: Dave_Saunders
Date: Wed, 14 Jan 2009 20:19
21 lines
1402 bytes
Rick,

You can also test for null or undefined rather than trigger an error. I usually do it like this:

var doc = app.activeDocument;  
var xrefFmt = getXRefFmt(doc,'Hoffman Accessory');  
alert(xrefFmt.name); 

function getXRefFmt(doc,formatName) {  
  var xrefFmt = null;  
  xrefFmt = doc.crossReferenceFormats.item(formatName);  
  if (xrefFmt == null) {  
    xrefFmt = doc.crossReferenceFormats.add({name:formatName});  
    xrefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.FULL_PARAGRAPH_BUILDING_BLOCK});  
    xrefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.CUSTOM_STRING_BUILDING_BLOCK,customText:', page '});  
    xrefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.PAGE_NUMBER_BUILDING_BLOCK});  
  }  
  return xrefFmt;  
}

Dave
Technical Details
Message-ID: <59b78308.2@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
References: <59b78308.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,49b15a73a3ef986c
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Dave_Saunders@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: [CS4 JavaScript] Adding a CrossReferenceFormat
Message-ID: <59b78308.2@webcrossing.la2eafNXanI>
Date: Wed, 14 Jan 2009 12:19:23 -0800
References: <59b78308.-1@webcrossing.la2eafNXanI>
Lines: 21
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit