Can't add placeholder text data merge for all blocks of text on the document

I'm trying to put together a script that loops if all pages in an indesign file, search all text frames label caption1, caption2, caption3... (whenever you get to a new page, the number of text images label starts again from 1) and add a placeholder in the text data fusion: caption1, caption2, caption3... but this time, when you get to a new page the number continues to go... caption4, caption5 and so on.

Page 1 - image text = caption1 = tag > data merge placeholder = < < caption1 > >

Page 1 - image text = caption2 = tag > data merge placeholder = < < caption2 > >

Page 1 - image text = caption3 = tag > data merge placeholder = < < caption3 > >

page 2 - text = caption1 = image tag > data merge placeholder = < < caption4 > >

page 2 - image text = caption2 = tag > data merge placeholder = < < caption5 > >

Currently, the script is adding placeholder text merge data only for the two text frames first (out of 6) on a page (about 8 pages) and just the first image of text on the page two (out of 3)

Any help will be greatly appreciated

Here's the script:

myDocument var = app.activeDocument;

-SOURCE DATA CALLS FUSION

main();

main() {} function

myDataSource var = File.openDialog ("Please select a datamerge source", "text files: * .txt");

If (myDataSource! = null) {}

myDocument.dataMergeProperties.selectDataSource (myDataSource);

myDocument.dataMergeProperties.dataMergePreferences.recordsPerPage = RecordsPerPage.MULTIPLE_RECORD;

}

}

-MERGE OF DATA FIELD

function get_field (captionString, myDocument) {}

fields var = myDocument.dataMergeProperties.dataMergeFields;

for (var f = 0, l = fields.length; e < l; f ++) {}

If (fields [f] .fieldName == captionString) {}

Returns the fields [f];

}

}

Alert ("error: did not find all the fields with the name" + field_name);

}

THE TEXT - ADD PLACEHOLDER DATA MERGE

var countFrames = 1;

for (i = 0; i < myDocument.pages.length; i ++) {/ / TOTAL NUMBER OF PAGES in the DOCUMENT}

var capPerPage = 1;

for (x = 0; x < myDocument.pages [i].textFrames.length; x ++) {//COUNT TEXT TOTAL IMAGES PER PAGE

If (myDocument.pages [i] .textFrames [x] .label < 0) {}

Alert ('can not find any image caption');

} ElseIf (.textFrames [x] myDocument.pages [i] .label == 'caption' + capPerPage) {//IF IT IS A TEXT LABEL of IMAGE 'caption1' EXECUTE

var captionString = "caption" + countFrames;

var myTextFrame = myDocument.pages [i] .textFrames [x];

var myDataMergeProperties = myDocument.dataMergeProperties;

var myTextFrame.parentStory = monarticle;

var myStoryOffset = myTextFrame.parentStory.insertionPoints [-1];

var myNamePlaceHolder = myDocument.dataMergeTextPlaceholders.add (monarticle, myStoryOffset, get_field (captionString, myDocument)); ADD DATA FUSION TEXT HOLDER TO THE TEXT BLOCK

countFrames ++; INCREASE THE NUMBER TO ADD DATA FUSION TEXT PLACEHOLDER FOR THE NEXT BLOCK OF TEXT

capPerPage ++;

}

}

}

Hello

To verify this change (replace for...) loop)

var countFrames= 0, currLabel, capPerPage;

for (i=0; i

Notice countFrames starts at 0.

Jarek

Tags: InDesign

Similar Questions

  • How can I add a text watermark in iphoto?

    How can I add a text watermark in iPhoto to protect my photos to be copied when I put them online? Or, is there another way I can fix?  I would like to publish pictures that will be for sale.

    This is not a feature of iPhoto

    You need additional software - you can do this by using the preview, PhotoShop, PS elements or one of many other graphic editors - you can do it with an opening - and there are plugins for iPhoto as BorderFX who can do

    LN

  • How can we add a text field on the stage, but without the text label?

    How can we add a text field on stage, but without the left text label by default?  I want just the field.

    I thought about it.  Go to the page layout palette and change the options of caption for the text box.

  • How can I add a new RSS feed for sidebar gadgets?

    I'm stuck with US new RSS on my sidebar gadget. How can I add a new RSS feed for sidebar gadgets?

    I added a RSS FLOW for the BBC (news, sport, etc.) to my "Favorites" internet, but when you browse gadgets sidebar 'options' menu drop-down only pick up "microsoft standard" stuff that is of the United States.  How the gadget captures the stream?

    To use Firefox as your browser:
    Firefox and Vista RSS platform
    http://www.netcrucible.com/blog/2007/01/25/Firefox-and-Vista-RSS-platform/

    t-4-2

  • Can I add an another logon user, for the finger swipe SimplePass 2012?

    Can I add an another logon user, for the finger swipe SimplePass 2012? I have an account, connect you with SimplePass 2012, but my wife does not work! I want so she is able to use my computer, but, to do so, she had have it me slide all the time! But, if it had its own log-in, it could slip into her own! If possible, very well! If not, then not much!

    SimplePass is a HP product, not a Windows utility. I recommend that you check the faq from HP.

  • How can we export itno csv data file for oracle forms

    Hello

    How can we export itno csv data file for oracle forms

    For example. I have the block called A.what never the data displayed on a block, when I click on a button, displays the block data, must be exported to the csv file.

    My application is running on the unix operating system.

    Please help on this.

    First of all.  What is your version of forms (for example: 11.1.2.2.0 not 11g).  Finally, who will use the .csv file?  If it is a user on their client computer - CLIENT_TEXT_IO TEXT_IO or WebUtil are standard packages used to export data to a file of Oracle Forms.

    The amount of data to be exported?  If you export only a couple hundred lines - export of Froms will be OK.  If you export more lines than that (300 + lines) then the export will be extremely slow to your username.  Keep in mind that forms is not designed to perform data exports - there are better tools available for this...

    Craig...

  • Why I can't add special text effects?

    Why I can't add special text effects?

    I want to add a shadow to text. How can I do?

    Serhiy salvation,

    What fonts do you use? Shadow effect can be applied to the system only fonts.

    Kind regards

    Aish

  • Can change us static text to the interactive course?

    Hi Experts,

    Is it still to change static text to the interactive course?. During the execution of my lot my display is as follows,

    From.jpg

    I want to change that during the lanterns as follows,

    To.jpg

    Can this be possible to change/add static text to the interactive courses, if so please suggest me the approach to achieve this.


    Note: I want to change the static contents of the static form.

    Thank you

    Raman C.

    Hello

    Exit 12.1, the 'Interactive edition' parameter has been added to text box objects.

    When this option is enabled, you can change the text in interactive or data entry failure Studio box

  • How to disable the placeholder text in the URL from the navigation bar and search fields?

    Everytime I open a new tab (often, the homepage is set to blank) I watch 'Go to site' in the navigation bar. The search field shows the name of the active search engine until the text is registration. All I want is to be able to do is disable the placeholder text, showing the two fields as white.

    Add code to the file userChrome.css below default @namespace.

    Customization files (interface) userChrome.css and userContent.css (Web sites) are located in the chrome folder in the user profile folder.

    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    
    *|*.textbox-input:-moz-placeholder { color:transparent !important; }
    *|*.textbox-input:-moz-placeholder:hover { color:graytext !important; }

    Use in Firefox 19 +:

    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    
    *|*.textbox-input::-moz-placeholder { color:transparent !important; }
    *|*.textbox-input:hover::-moz-placeholder { color:black !important; }
  • JS script to add custom text and the name of file to file info in the title of the document

    Would be very happy for any help with this one...

    JS script add custom text and the name of file to file info in the title of the document

    Thank you very much

    Super: O)

    I have a folder of say 50 images and I want to run a lot of JS script

    example in the title of the document: image Nr 81205

    custom text is 'image Nr' + '81205 file name.

    activeDocument.info.title ="Nr of pictures"+ decodeURI(activeDocument.name);

    This would be correct without seening the ext file

    Thank you very much

  • I can't change my ringtone (default) open for ringtones that I bought on the iTunes store. iOS 9.2. U CN understand? Thank you

    I can't change my ringtone (default) open for ringtones that I bought on the iTunes store. iOS 9.2. U CN understand? Thank you

    Hi go to settings - sounds - ringtones if the one, s you purchased are

    Not on the list, go to restoretones.apple.com

    See you soon

    Brian

  • Envy 17 2180el can I add a second hard drive, and then choose bios/boot of the system with which to start?

    Envy 17 2180el can I add a second hard drive, and then choose bios/boot of the system with which to start?

    in the case give me the link of a hard disk of type to add

    Hello

    While you can certainly add another HARD drive in the Bay of secondary drive (you must also support and the connection cable) you can't boot from it - only in the Bay of primary HARD drive is bootable.

    Kind regards

    DP - K

  • When using PDF documents for signature, you need to 'send' the document for signature? Alternatively, can I publish the document on my site and just ask visitors to sign without send me to each person, when using PDF documents for signature

    When using PDF documents for signature, you need to 'send' the document for signature? Or can I publish the document on my site and simply ask visitors to sign without send me to each person?

    Hello

    You can use the Widget feature to publish the document on your website. Here is the link for reference:

    https://helpx.Adobe.com/document-cloud/help/create-widgets.html

    -Usman

  • [C++] Events to detect changes to text in the document

    Hi all

    I use C++ to develop a plugin for InDesign. During development, I want to catch the events of changing text in the document open in InDesign. The events are something like adding or deleting certain characters or words or phrases in the document. Those can be understand that the events occurred when the user change or remove the text in the document.

    When the events are detected, they should provide what characters, words or phrases are added or removed from the document. In addition, they should provide the index of the text changes if they are able to do.

    Please help me with this problem by providing methods, functions or libraries can detect changes to text in InDesign.

    Sincerely,

    Tri Dung

    Hi Tri Dung,

    Check the API TextPreProcessService and TextPostProcessService. You can write your own services and implement the interfaces ITextCommandPreProcess and ITextCommandPostProcess.

    Markus

  • Why Apple can't do two systems? First of all, we are protected, and the other is free just like android, but in the style of the iOS and Apple needs a request so we can manage and see new products from an application and do not go on this site!

    Why Apple can't do two systems? First of all, we are protected, and the other is free just like android, but in the style of the iOS and Apple needs a request so we can manage and see new products from an application and do not go on this site!

    and I don't know that if Apple make a system more freely, there no need for any device on Earth but iPhone.

    http://www.Apple.com/feedback/

Maybe you are looking for

  • Exchange of records between HP laptops

    I have a HP Folio 13-1000ea with a SSD Windows 7 Professional and I just bought a HP Pavilion 14 "Sleekbook 14-B109SA with a standard Windows HARD disk 8. I want to swap the disks hard, and then re - install the respective operating systems.  Can som

  • 8710 toner

    I have a new Officejet 8710 to replace my 8600 Officejet. Ink toner cartridges seem to be the same XL 951 and 952 XL. I kinda left my 8600 951. It will work in the 8710? I read onilne they exchange. ????

  • cannot replace the print cartridges CP1025nw

    I am trying to replace the print on my HP LaserJet CP1025nw cartridges.  I did several times.  But this time, I can not cartridges suitable for turning in place.  I press any button to specify which cartridge I want to replace, only yellow appears! 

  • Error: Software of "Operation not valid Floating Point" as he tried to run Iolo drive scrubber

    Original title: cannot run A clean product Up I ran Drive Scrubber from Iolo now for 2 consecutive years. Now when I try to run it, it gives me an error message that says "invalid Floating Point Operation". I don't have any idea what it is. What is a

  • HttpConnection and digest authentication

    Hello! I'm doing a HttConnection with digest authentication and I get the error message: "Stream not in installation status. First I open a url and get the instance of HttpConnection, then I get "www-athenticate" the server response header field. It