Problem replacing content in text frame

I am bumping my head against this. Its something I thought I know. I have a labeled text frame when I alert(mySpineTxt.getElements()); it tells me [object TextFrame] that sounds good to me then I use this
if(mySpineTxt.getElements().length != 0){
    with(mySpineTxt.parentStory.words.itemByRange(0,0)){
            mySpineTxt.contents=(String(myResp))
and it tells me that mySpineTxt does not support parentStory. I think it should.
Please add any corrections that I am missing.

#targetengine "session"
//Creates a simple event listener.
main();
function main(){
    var myEventListener = app.addEventListener("beforePrint", dateChanges, false);
    var myEventListener = app.addEventListener("beforeSave", dateChanges, false);
    //var myEventKill = app.addEventListener("beforeClose", killDate, false);
function dateChanges(){
     var myDocument = app.activeDocument;
var myPageItems = myDocument.pageItems.item("myDateLabel");
if(myPageItems==myPageItems){
if(myPageItems.getElements().length != 0){
    //alert ("I want to change your date")
    var myDateText=myPageItems
var myDate=new Date();
    myDate=String(myDate);
    myDate=myDate.slice(0,15);
    myDate=myDate.slice(4,15);
    alert(myDateText);
    with(myDateText.parentStory.words.itemByRange(2,4)){
                    contents=(    ""+myDate)
}//ending bracket for dateChanges function
function killDate(){
app.removeEventListener("beforePrint", dateChanges, false);}
this is an event listner that changes the date. This works when I use myDateText.parentStory when I plug it in to the other script i am using same stuff. it doesn't work its object is also listed as a page item.

Similar Messages

  • How to replace content in text data type?

    How to replace content in text data type? 
    when we sending the mails we are taking content from the database.
    The data is maintained in text data type column. Now i have to replace some of content in mail content
    (text data type column) from database. 
    I tried by using REPLACE function but data is truncated

    The data is maintained in text data type column.
    Hello,
    See REPLACE (Transact-SQL) => "If
    string_expression is not of type varchar(max) or
    nvarchar(max), REPLACE
    truncates the return value at 8,000 Bytes"
    You may should consider to Change the data type from "Text" (deprecated) to NVarChar(max).
    Otherwise you have to use
    UPDATETEXT (Transact-SQL) for the text data type.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Problem with master page text frame

    I am using ID 4 on a Mac with Snow Leopard 10.6.6. I have created a master with facing pages and master text frame. But the pages based on that master do not have any text frames showing. When I go to Document Setup the Master Text Frame checkbox is ticked, but the tick and the words "Master Text Frame" are greyed out.
    I have deleted and reinstalled ID4 and  have renamed the InDesign Defaults and InDesing SavedData preference files but no improvement.
    I have to place or copy and paste quite a few pages and don't want to create text frames for every page.

    Do you mean CS2, version 4, or CS4, version 6? My guess is the former since that seems to behave exactly as you describe with the master frame option inaccessible after you've set up the file. In CS2 the master frame is there, but you don't see it on the document page if it is the same size as the margin guides because they obscure the frame edge. If the Ctrl (Cmd) + Shift + Click in the frame area you should see it become visible as it is overridden and selected.
    Aside from that, everything in the first two responses is dead on. If the master frame is the size of the margin guides, it's totally superfluous for normal work and more of a hindrence than a help.

  • Adding HTML content in text frame

    I'm a little bit frustrated when adding some copy to edge. In order to add a simple hyperlink for example in my paragraph of text, I need to use the replace text field where I can add the <a href..>
    and change it over before it's viewed.
    Is there any plans on making this easier? Or is there better workaround?
    Thank you.

    EW wrote:
    That is correct.> In old versions of Planning if you knew how to write html you could add stuff into the instructions that could be a hyperlink and could be edited for fonts size and color etc.
    >
    This is no longer available based on the base code changing and no longer allowing it. Other might have suggestions on how to make so that works again but way I know handle this is through "menus". In menus you can add hyperlinks to other stuff.
    Well I thought it changed back in later versions 11.1.1.3.04 (I know not much use if you are on earlier versions) :- 9475065 – Users cannot use HTML commands in data form and task list instructions.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • [AS] Applescript - Duplicate paragraph from one text frame to end of second text frame?

    Working in InDesign CS5
    Still banging my head against the wall over this last bit of code I need to figure out to finish a much larger script. What I'm looking to do is take a paragraph ('contents' from looping in larger script) from one text frame and duplicate it to the END of a second text frame (represented by 'Ad_Box'). The only thing I've gotten to semi-work is this:
    set insertion point -1 of Ad_Box to contents
    The problems with the above script are:
    1. Minor problem (can be worked around in InDesign CS5) - The script does not keep the formatting from the original paragraph that I want duplicated. The paragraph style of all "inserted" paragraphs is set to default
    2. The big problem - When the second text frame is too small for a particular word in original paragraph, the paragraph is moved to the wrong position in the text frame when the script completes, which is moving 4 paragraphs in total (this one baffles me). In other words, if I'm running script to be p1, p2, p3, p4 and p2 had a word too long to fit in text frame, on completion it will look like p1, p3, p4, p2.
    This is why I'm hoping to use the DUPLICATE command in some capacity, but I'm stumped. I set up a dialogue prompt to help me debug, and whenever I use the DUPLICATE command my script skips right over the dialogue, so I know it's not reading properly. This is what I've tried with no luck. Any help would be greatly appreciated.
      duplicate contents to insertion point -1 of Ad_Box

    Mary, you were absolutely correct!! This fixes the problem of placing the contents into the wrong spot, AND it runs the script much faster too! Thank you.
    However it is still not carrying over my "applied paragraph style" that is on "contents". Does 'insertion point' not work this way?
    What looks like is happening is that in the InDesign app, whatever my default selected paragraph style is is what the insertion point type is placing as.
    I might try to set my applied paragraph style after the "last insertion point" call and see if that works. I'll update this reporting results

  • What is the best way to import a graphic? & How do I create a text frame for a figure caption?

    Hello all! I've been working from the FM book for almost 2 hrs trying to figure this out, so now I need your help. I am almost to this point:
    Problem I: Importing a graphic
    First of all, which is the best way?
    -Insert an anchor frame and then import the graphic into the frame OR
    -Just insert the graphic and get the anchor frame by default
    Here’s my importing and sizing problem:
    I hit ENTER to make a new paragraph line (side note: the book says make a new paragraph by hitting ENTER, import the graphic, and then ESC m+p to shrink wrap so that you can avoid the graphic overlapping the above text. I do exactly this (I believe), but my graphic still overlaps the above text when I shrink wrap. What the...?)
    I insert an anchored frame with position Below Current Line and alignment CENTER (I chose to the insert anchor frame, since this way I have control over its alignment, correct?)
    Anchor frame is selected when I import my image file
    In the Imported Graphic Scaling box, what do I select if my file is HUGE (3072x2304)?
    -Fit in selected rectangle (when I choose this the image imports small and fits in the anchored frame with lots of white space around it)
    -72 dpi
    -75 dpi
    -150 dpi
    -300 dpi
    -Custom dpi: 96 (I’ve tried changing this to a smaller number (20) and I get a message that says “cannot handle a bitmap of that size.”)
    I’ve had the best luck with selecting FIT IN SELECTED RECTANGLE, and then I just scale the image with my shift+click. If I choose 72 dpi or Custom, my image imports HUGE, and I just can’t manage it. I don’t have a method for resizing these images outside of FM.
    Problem II: Creating a text frame for a caption
    Once I have chosen FIT IN SELECTED RECTANGLE, I try to insert a text box underneath the image (and inside the anchor frame) to type a caption in it.
    In Create New Text Frame box, the default is Number 1 and Gap 0.25. I click SET.
    Next, I double-click inside the text frame to begin typing, but the cursor is OUTSIDE and UNDERNEATH the text frame! What the heck??? I’ve done this before and it has worked just fine. Then I had another problem where when I did get the text inside the text frame, I would select the text frame to move it, and it left the text behind! (I moved the frame but the text was separated from it and left behind.)
    THANK YOU in advance for your help. I hope I wrote this out clearly enough. I appreciate those who respond. P.S. I'm in FM 10.

    My favorite method is to use a one-cell table for graphics and captions.
    Import the graphic by reference into the table cell. Create a "Caption"
    paragraph tag and assign it to the table title. (The title can be set
    for above or below the table cell. I prefer below.) Now, whenever you
    insert this table, it will be ready for graphic and caption. Another
    advantage of this method is that graphic and caption always stay
    together at page/column breaks.
    When you create the table format above, assign it to have a -2.0 space
    above. Then, create a paragraph tag, such as "TableAnchor" and assign it
    -2.0 pt font size and -2.0 space below. (You can substitute a different
    point size, but it must be the same in all three places. The TableAnchor
    paragraph will hold the table and these settings let tables fit against
    the top margin where necessary. Otherwise, they dip down a bit.
    I wrote this from memory, so I hope I remembered all the steps!

  • [AS] Access Text Frame Labels in CS5

    Hello Everyone,
    I am updating a CS2 InDesign AppleScript to CS5 and finding an issue accessing the text frame labels. In CS2 the script below would set the variable x to the contents of the text frame "bob", unfortunately, this script not longer works in CS5.
    tell application "Adobe InDesign CS2"
            set x to contents of text frame "bob" of active document
    end tell
    The documentation tells users how to insert text, but not access it. If anyone has an idea of how to do this in CS5 I would appreciate it.

    Got it!
    tell application "Adobe InDesign CS5"
         tell active document
              set x to contents of item 1 of all page items whose label is "bob"
         end tell
    end tell

  • Script to select all overflow text frames and fit them to content?

    I have a document with several text frames that have overset text, due to replacing a font.  I was looking for a script that would:
    1. find all the text frames that have overset text
    2. apply "fit frame to content" command for each of these
    Can anyone please help me here?  I'm trying to learn scripting but some of these things still confuse me.  Thanks.

    hi,
    give a try to this js code:
    var _d = app.documents[0];
    var _allStories = _d.stories;
    for(var n=_allStories.length-1;n>=0;n--){
    var _storyAllTextFrames = _allStories[n].textContainers;
    for(var m=_storyAllTextFrames.length-1;m>=0;m--){
    _storyAllTextFrames[m].select();
                //Fit Frame to Content:
                try{
                app.scriptMenuActions.itemByID(11291).invoke();
                    }catch(e){};
               try{
               app.scriptMenuActions.itemByID(278).invoke();
                    }catch(e){};
    Disclaimer:
    I'm NOT a scripter. Sorry, don't remember exact origin of this code, but it works...

  • Polulate Text frames with XML content - PLEASE help me.

    Hi guys,
    I'm trying to import some xml data to an indesign file. Here are the steps I'm doing:
    1- create new document
    2- create master page
    3- create empty text fields in the master to be tagged
    4- import tags from xml
    5- import xml
    then it simply don't auto populate the text fields wiith the xml content.
    I've already spent about 10 hours trying to figure out what can be the problem...
    My structure in indesign (BEFORE importing XML):
    businesscards
    Card
    employeeName
    employeePosition
    employeeAddressln1
    employeeAddressln2
    employeePhone
    employeeEmail
    My structure in indesign (AFTER importing XML):
    businesscards
    Card <!-- has dropdown arrow with xml content inside -->
    Card <!-- has dropdown arrow with xml content inside -->
    Card <!-- has dropdown arrow with xml content inside -->
    Card <!-- has dropdown arrow with xml content inside -->
    employeeName
    employeePosition
    employeeAddressln1
    employeeAddressln2
    employeePhone
    employeeEmail
    But it doesn't populate the text frames...
    I've already tried to write text in the text frames and tagged them, so I can see those colored brackets. But it doesn't work and makes a mess in the structure.
    Please, can someone help me, do you know a good step by step tutorial online? What am I doing wrong?
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <businesscards>
    <Card>
    <!-- contents of Suzan Reed -->
    <employeeName>Suzan Reed</employeeName>
    <employeePosition>Director of Marketing</employeePosition>
    <employeeAddressln1>506 SE 72nd Avenue</employeeAddressln1>
    <employeeAddressln2>Portland, Oregon 97215</employeeAddressln2>
    <employeePhone>503-481-5858 direct</employeePhone>
    <employeeEmail>[email protected]</employeeEmail>
    </Card>
    <Card>
    <!-- contents of Gabriel Powell -->
    <employeeName>Gabriel Powell</employeeName>
    <employeePosition>Senior Training Director</employeePosition>
    <employeeAddressln1>25 NW 23rd Place, Suite 6-122</employeeAddressln1>
    <employeeAddressln2>Portland, Oregon 97210</employeeAddressln2>
    <employeePhone>503-515-5404 direct</employeePhone>
    <employeeEmail>[email protected]</employeeEmail>
    </Card>
    <Card>
    <!-- contents of Dale Erwing -->
    <employeeName>Dale Erwing</employeeName>
    <employeePosition>Trainer</employeePosition>
    <employeeAddressln1>5131 Buffalo Ave. #20</employeeAddressln1>
    <employeeAddressln2>Sherman Oaks, CA 91423</employeeAddressln2>
    <employeePhone>310-795-8943 cell</employeePhone>
    <employeeEmail>[email protected]</employeeEmail>
    </Card>
    <Card>
    <!-- contents of Jim Conner -->
    <employeeName>Jim Conner</employeeName>
    <employeePosition>Trainer</employeePosition>
    <employeeAddressln1>25 NW 23rd Place, Suite 6-122</employeeAddressln1>
    <employeeAddressln2>Portland, Oregon 97210</employeeAddressln2>
    <employeePhone>503-515-2376 cell</employeePhone>
    <employeeEmail>[email protected]</employeeEmail>
    </Card>
    </businesscards>
    Thanks in advance

    It worked! thanks ... But...
    But only if I don't apply to the Master when I apply to the master all the other cards have the same content as the first of the XML. :(
    Even when I try to create multiple pages (cards) with no Master page (too time consuming), I can't figure out a way of having the other cards filed with the remaining data of the XML. :(
    I don't want to drag the elements one by one to every single card (they are so many...)
    Is there a way of having the structure organized in a way to have indesign auto populate and auto create pages?
    thanks for any kind of advice.

  • Problem with text frame dropshadow not completely printing to pdf file.

    Hi and thanks for your speedy replies!
    I am editing a file that had altered corner text frames with a .25 inset and a drop shadow added, .05 stroke and paper swatch. When I deleted text everything shifted so I had to recreate the special frames on select pages. These new text frames are not showing the top and left sides of the frames when saved to pdf file. The right and bottom drop shadow are showing.  What am I missing?
    Cheers!

    I am using the latest version in CC. I tried several exports directly from ID, PDF/X-3:2002, PDF/X-1a:2001 and the low res setting, all with no changes.  None showed the left or top border on the frames in question.
    So I was getting the first screen shot instead of the second which other similarly formatted frames showed.  I checked every setting I could find and they were all the same.  The problem just occurred after the point in the doc that I had made changes resulting in some pages being deleted and the page formatting being thrown off which I corrected with the appropriate saved page formats.  But when I went to set up the frame dropshadow and accompanying stroke and swatches, the outline just would not show in the pdf although it appeared to be showing in ID.
    I've since discovered a work around for the editing so no pages were deleted, but I need to figure out why this happened and what I am not seeing. Perhaps a setting to show the border? Or maybe it is some overall setting that I need to be looking for? Just weird, weird, weird...

  • Problem in copying a text item content in forms 10.1.2 to other application

    Hi all,
    I have just upgraded my Form server 6i in Windows 2003 to to Application server 10.1.2 in Linux.
    In previos version Application Users Used to Copy some texts from other Applications like Windows NotePad or Client/server Version of Application to webforms text items or vice versa.
    In Application 10g it doesnt work. whithin the webforms we can copy and past content of texts but within Applications It doesnt wirk at all.
    we are running Forms 10.1.2 on Windows XP, using windows IE as the browser.
    Does Forms 10.1.2 use its Own clipboard?
    does anybody know any workaround to solve the problem?
    thank you in advance.
    Alireza

    Hi Mark,
    Thanks for your attention,
    I Think it's not the certification mater, because in development environment I have Stand alone OC4j installed in Windows Xp witch uses the same version of Jinitiator and copy/paste functionality works fine.
    Surprisingly when I connect to application server 10.1.2 witch is installed in Enterprise Linux from the same PC the functionality does not work.
    I cheked windows clipbord before and after running the form application from and noticed that copy/paste mechanism of form doesnt effect windows clipbord ant it somehow uses a private clipboard within itself.
    Any solution would highly be appreciated.
    Thank you in advance.
    Alireza.

  • Table of contents and the order of multiple text frames flowing across pages

    I have a multi-page document,
    on each page, there are 2 text frames:
    - A text frame for containing a PAGE TITLE
    and
    - A text frame, flowing from one page to another containing: a MAIN TITLE, a SECTION TITLE, and flowing body copy (on page 1); and another MAIN TITLE, a SECTION TITLE, and flowing body copy; (on page 2)
    When I generate a TOC, using the Page, Main and Section Titles styles, the expected outcome would be:
    Page Title             1
       Main Title           1
    Section Title          1
    Page Title             2
       Main Title           2
    Section Title          2
    But because the Main title and Section titles are all within one flowing text frame and the content flows across multiple pages, and each of the Page Titles are within 2 separate text frames, the actual TOC generated is:
    Page Title             1
       Main Title          1
    Section Title         1
       Main Title           2
    Section Title          2
    Page Title             2
    ...where the TOC lists all the TOC items from the flowing text frame in one grouping first, then the individual free standing text frame title.
    QUESTION: Is the only way to automatically rectify this is to combine all the text into one flowing text frame? or is there another workaround?
    Have played with the left/right, top/bottom alignment of the individual text frames; also experimented with the object layering, to no avail..
    Thanks for any insights.

    I ended up using a product called InFlow from EmSoftware.  The solution offers a plugin to InDesign that builds pages on the fly when there is overset text.  The setup is pretty minimual and it seems easy to use.  The only drawback that the plugin MAY have is that it does not remove the pages it built if the pages are not needed from record to record.  I could not test this myself since my test data did not test more then one record, but when I turned my proof set off, the pages that were built were still on screen.  It does seem to work well for what we are looking to do, so if anyone is looking for something that will build pages on the fly in situations where the "Dynamic Story Handling" is not available, I would suggest looking into this.

  • Best SEO practices for text frames in content areas

    Hello,
    Is it best practice for SEO to keep all text (H1, H2, H3 <p> etc.) on a web page in one text frame and adjust with spacing between paragraphs to add additional elements (Video, widgets etc.) or is it better to use separate text boxes and place elements between them?
    Thanks! Below is an example. Should the H1 and both paragraphs be in one text frame space out to fit video or two separate text frames with the video between them?
    What is Lorem Ipsum?
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

    In the example you give, I would put both sets of text in a single box with a blank spacer between them for the video which would then be layered over the top to appear in the middle.
    The video takes longer to download and may also be blocked by the users settings so having it separate allows my text to load (and appear) quickly even if the video encounters issues.
    I would only separate the two text sections if they are clearly different in style or content and that’s really only helpful if you want a phone and/ or tablet version of your pages… it makes your life easier then to have the text in separate containers when you want to sync them across the different layouts.

  • How to create, place, format and paste the clipboard contents into a text frame

    I am new to scripting and need help. I have an existing Indesign document. I need to be able to create a text frame on my current page, the width of my margins with the top of the text frame at the top margin and 1" in height, then format it to be 1-column, and then paste the clipboard contents into it and tag the text with a particular paragraph style. I am using Indesign CS4 on a mac, if that makes any difference. Thanks for any help.

    May this will help you. It will create an anchored object with a text what you desired, with object style. You should create an object style before with the x and y co ordinates. You can choose either para style or character style.
    var the_document = app.documents.item(0);
    // Create a list of paragraph styles
    var list_of_paragraph_styles = the_document.paragraphStyles.everyItem().name;
    // Create a list of character styles
    var list_of_character_styles = the_document.characterStyles.everyItem().name;
    // Create a list of object styles
    var list_of_object_styles = the_document.objectStyles.everyItem().name;
    // Make dialog box for selecting the styles
    var the_dialog = app.dialogs.add({name:"Create anchored text frames"});
    with(the_dialog.dialogColumns.add()){
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Make the anchored frames from ..."});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"This character style:"});
    var find_cstyle = dropdowns.add({stringList:list_of_character_styles, selectedIndex:0});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Or this paragraph style:"});
    var find_pstyle = dropdowns.add({stringList:list_of_paragraph_styles, selectedIndex:0});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Leave one dropdown unchanged!"});
    dialogRows.add();
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Delete matches?"});
    var delete_refs = dropdowns.add({stringList:["Yes","No"], selectedIndex:0});
    dialogRows.add();
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Anchored text frame settings:"});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Object style:"});
    var anchor_style = dropdowns.add({stringList:list_of_object_styles, selectedIndex:0});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Frame width:"});
    var anchor_width = measurementEditboxes.add({editUnits:MeasurementUnits.MILLIMETERS, editValue:72});
    with(dialogRows.add()){
    staticTexts.add({staticLabel:"Frame height:"});
    var anchor_height = measurementEditboxes.add({editUnits:MeasurementUnits.MILLIMETERS, editValue:72});
    the_dialog.show();
    // Define the selected styles
    var real_find_cstyle = the_document.characterStyles.item(find_cstyle.selectedIndex);
    var real_find_pstyle = the_document.paragraphStyles.item(find_pstyle.selectedIndex);
    var real_anchor_style = the_document.objectStyles.item(anchor_style.selectedIndex);
    // Check if a style is selected
    if(find_cstyle.selectedIndex != 0 || find_pstyle.selectedIndex != 0) {
    // Define whether to search for character styles or paragraph styles
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    if(find_cstyle.selectedIndex != 0) {
    app.findGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.appliedCharacterStyle = real_find_cstyle;
    } else {
    app.findGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.appliedParagraphStyle = real_find_pstyle;
    app.findGrepPreferences.findWhat = "^";
    // Search the document
    var found_items = the_document.findGrep();
    myCounter = found_items.length-1;
    do {
    // Select and copy the found text
    var current_item = found_items[myCounter];
    if(find_pstyle.selectedIndex != 0) {
    var found_text = current_item.paragraphs.firstItem();
    var insertion_character = (found_text.characters.lastItem().index) + 1;
    var check_insertion_character = insertion_character + 1;
    var alt_insertion_character = (found_text.characters.firstItem().index) - 1;
    var the_story = found_text.parentStory;
    app.selection = found_text;
    if(delete_refs.selectedIndex == 0) {
    app.cut();
    } else {
    app.copy();
    } else {
    var found_text = current_item;
    var insertion_character = (found_text.characters.lastItem().index) + 2;
    var check_insertion_character = insertion_character;
    var alt_insertion_character = (found_text.characters.firstItem().index) - 1;
    var the_story = found_text.parentStory;
    app.selection = found_text;
    if(delete_refs.selectedIndex == 0) {
    app.cut();
    } else {
    app.copy();
    // Make text frame from selection
    try {
    app.selection = the_story.insertionPoints[check_insertion_character];
    app.selection = the_story.insertionPoints[insertion_character];
    } catch(err) {
    app.selection = the_story.insertionPoints[alt_insertion_character];
    var the_anchored_frame = app.selection[0].textFrames.add({geometricBounds:["0","0",anchor_height.editContents,anch or_width.editContents],anchoredObjectSettings:{anchoredPosition: AnchorPosition.ANCHORED}});
    app.selection = the_anchored_frame.insertionPoints[0];
    app.paste();
    // Apply the object style now to "force apply" paragraph style set in the object style
    if(anchor_style.selectedIndex != 0) {
    the_anchored_frame.appliedObjectStyle = real_anchor_style;
    myCounter--;
    } while (myCounter >= 0);
    } else {
    alert("No styles selected!");

  • [JS][CS3] Change the content type of a text frame

    Hi,
    a bit basic maybe but I'm stuck on this from an hour...
    I need a textFrame to become a graphic object.
    The textFrame has no content.
    How can I change the contentType on that object?
    Thanks anticipately.

    This looked like an interesting challenge, so I'm taking a shot at it. I created a new document and added three text frames (unpopulated) to the first page. I tagged them "Image", "Caption" and "credit". I then exported as a snippet, deleted the document and opened another new one. Then I placed the snippet (so far, everything has been manual -- no scripts) and indeed, the snippet placed and the frames were added to the document's structure and were properly tagged -- the three tags were automatically created by the action of placing the snippet.
    So, let's duplicate this in a script. Even though I know exactly where the snippet is, I'm going ask the user to find it. That way, I eliminate the issue of getting the path to the snippet wrong:
    var myDoc = app.documents.add();
    var myPage = myDoc.pages[0];
    var myPlacePoint = [myPage.marginPreferences.left, myPage.marginPreferences.top];
    var mySnippetFile = File.openDialog("Choose the snippet");
    if (mySnippetFile == null) { exit() }
    var mySnippet = myPage.place(mySnippetFile, myPlacePoint);
    And that worked. The snippet is on the page exactly where I wanted it. So, now we need to find the text frame that has the "image" tag. First, we must explore just what mySnippet consists of.
    OK, it's an array of three stories. That's a tad weird. Why isn't it an array of three text frames? I wonder what would happen if two of the frames in the snippet were threaded -- but let's address that later after we solve the immediate issue. The point is that we know that the snippet consists of three separate text frames that aren't threaded. So:
    for (var j = mySnippet.length - 1; j >= 0; j--) {
         var myTag = mySnippet[j].associatedXMLElement.markupTag.name;
         alert(myTag);
    And this gives me the three tags (and reminds us that when you tag a text frame you're also tagging the story that holds it. So:
    var myDoc = app.documents.add();
    var myPage = myDoc.pages[0];
    var myPlacePoint = [myPage.marginPreferences.left, myPage.marginPreferences.top];
    var mySnippetFile = File.openDialog("Choose the snippet");
    if (mySnippetFile == null) { exit() }
    var mySnippet = myPage.place(mySnippetFile, myPlacePoint);
    for (var j = mySnippet.length - 1; j >= 0; j--) {
         var myTag = mySnippet[j].associatedXMLElement.markupTag.name;
         if (myTag === "Image") {
              var myFrame = mySnippet[j].textContainers[0];
              myFrame.contentType = ContentType.graphicType;
              break;
    And that does the job.
    Thomas,
    You were very close but you forgot that the text frames that make up a story are addressed as textContainers from CS3 onwards. Your code would have worked in CS2.
    Dave

Maybe you are looking for