How do I apply style within a text frame linked object

I'm selecting the text frame in the object I want to apply an object style
A script can be written
within a text frame the linked object (selected text frame)
how object style is applied

Hi
All you need is
app.selection[0].appliedObjectStyle = app.activeDocument.objectStyles.itemByName ("Trevors Object Style");
The below snippet will apply the style to all the anchored objects in the selection or document
var doc = app.properties.activeDocument,
    myOnjectStyle = doc.objectStyles.itemByName ("Trevors Object Style"),
    myObjects, l;
if (!myOnjectStyle.isValid) {
    alert ("Either add an Object Style Called:\nTrevors Object Style\nOr Make Significant Changes to The Script");
    quit ();
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "^a";
myObjects = (app.selection && app.selection[0]).findText () || doc.findText ();
l = myObjects.length;
while(l--) myObjects[l].textFrames[0].appliedObjectStyle = myOnjectStyle;
HTH
Trevor

Similar Messages

  • How to give Bold style inside Single Text Frame

    Hi
    I created a text frame with some text in it. It comes in three paragraphs. First para is the title with two words and below two are small description. All the text is kept in single textframe and I need that to be in single frame only. NOW, I need to bold the first para that is the title with two words. How can I write the code to give bold style to the first paragraph inside that frame? Do I need to take different frame? I want all in single actually. Also I want the entire text frame to give my customized text color.
    Hoping a valuable suggestion
    Thanks in advance.
    Regards
    P

    Dave, Good questions(s)!!! Details below...
    It's CS2. I need to put some text in all (many) documents I work regularly. Instead of copying from the previous file or any other source, as the text is same for all, I thought of writing the script with the text itself. Running that will create text frame and write the text. Got almost but was unable to bold the title of the text which I mentioned earlier as a first paragraph with two words.
    Also I couldn't give the my color swatch to the text.
    Here is my script:
    var myTextFrame = app.activeWindow.activePage.textFrames.add()
    var myParagraph = myTextFrame.paragraphs.item(0)
    var myFont = app.fonts.item("Arial")
    myTextFrame.geometricBounds = ["11.2in", "6in","9.57in","0.5in"];
    myTextFrame.contents = "First Paragraph"
    myTextFrame.parentStory.insertionPoints.item(-1).contents = "\r This is Second paragraph.";
    myTextFrame.parentStory.insertionPoints.item(-2).contents = "\r\rHere comes the Third Paragraph with extra para space";
    myParagraph.parentStory.appliedFont = myFont
    myParagraph.parentStory.pointSize = 8
    myParagraph.paragraphs.item(-1).spaceAfter = "0.05in"
    myTextFrame.fit(FitOptions.frameToContent)
    Hope this answers all your questions. Waiting for valuable solution. Have another question will ask after I got this. For now, two questions 1) making bold first two words 2) font color

  • Add style to large block of text without affecting existing styles within that text

    Hello! First post here.
    I have a long document of text that mostly does not have text styles attached (this was a mistake). However, there is a large number of areas of styled text within.
    Is there a way to select all the text and apply a style to only the unstyled text without affecting the existing styles?
    Doing this by hand text block by text block would take a long long time.
    Any help is greatly appreciated.
    THX!
    Ian

    winterm wrote:
    What do you mean by "unstyled text"? It must have some definition, anyway.
    Like others, [No Paragraph Style] and [Basic paragraph] are searchable, too.
    boomshakalaka! Thanks! Im familiar with this panel but didnt see how to specify 'Character Style: [No Character Style]'.
    Had to click on the icon

  • How to handle paragraph styles in imported text with no tagged paragraph styles

    Hi
    Im currently trying to import a file (word file / excel I have both formats) into an indesign book and formatting the text automatically!
    My question is: How is it possible to reflow text into frames and when changing frame it changes paragraph?
    Or how is it possible to change paragraph style when forcing a line break when using text reflow?
    I have already figured out how to reflow the text, and actually also managed to relow text into the frames and change paragraph style. I know how to use the keep option, and by this change the paragraph style when e.g. changing frame break/page break etc.  (but if the content being flowed-in is not tagged with style names then I cannot figure out how to do it) The document and its content I whish to import do not have any tagged paragraphs!
    Then I tried to look into "object styles" and format a text frame on a master page with an object style, and by using a "dilimiter character" forcing the text to start in a new frame when bringing the frame into live on a page. But here I cannot make the "text frame/object style" to apply or to work.
    If any of you have a hint, I would be more than happy to hear from you
    This picture are illustrating the outcome I would to get to....

    If the incoming text does not have styles, or has only one style, there is really not much you can do other than assign styles after the import. If there are recognizable patterns in the formatting, a lot of that can be done with Find/Change, and there are a few scripts floating around that can help automate some of that.
    Also, if your styles have a a good "next style" heirarchy built in, you can select large blocks of text (up to the point where applying next style would be incorrect), then right click the style name in the paragraph styles panel and choose apply style and next style (remove overrides). Warning. Removing overrides will remove any locally applied formatting like bold or italics, so local formatting should be converted to character styles first. Applied character styles are not overrides and will be preserved.

  • How do you make a customized template?? When I customize an original template it does not apply it to the whole document! How do you apply style changes permanently to your document???

    When one customize text styles or spacing between paragraphs. How do you apply settings permanently to a document???
    Should you create a new template???

    Happily, when you edit a document created by a given template, the changes aren't stored in the template.
    If you want to get a template embedding your changes, you need to use :
    File > Save as Template
    then use the newly created custom template as starting point.
    Yvan KOENIG (VALLAURIS, France) dimanche 22 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My Box account  is : http://www.box.com/s/00qnssoyeq2xvc22ra4k
    My iDisk is : http://public.me.com/koenigyvan

  • Apply different font styles in single text frame

    hi all
    how can i apply different font styles in a single text frame using indesign script ?
    for example :
    "dasdnasndasndlasndnasdlasdasdas"
    may i know is it possible to do that and how to do that ?
    thanks

    You can set (as well as read) every single property of any text range with scripts. This is javascript; it assumes you text cursor is inside a frame with some text.
    * Setting some specific characters to a color:
    app.selection[0].parentStory.characters.itemByRange(5,10).fillColor = "Red";
    * Change the font of words:
    app.selection[0].parentStory.words[3].appliedFont = "Arial\tBold";
    * .. or just the style:
    app.selection[0].parentStory.lines[2].fontStyle = "Italic";
    * .. or any other attribute (this one requires you to have at least 5 characters selected):
    app.selection[0].characters[5].underline = true;
    Of course these operations are not limited to something you select; they work the same with any text frames you can refer to.
    app.activeDocument.textFrames[1].paragraphs[2].appliedCharacterStyle = "charstyle";

  • InDesign CS3 crashes when applying styles to pasted text with formatting.

    Running InDesign CS3, v. 5.0.2 on Windows XP, SP2
    InDesign is crashing whenever I do the following:
    1. Paste or place text from Microsoft Word -- with existing formatting preserved.
    2. Apply any character or paragraph style to that text.
    This happens 100% of the time when I try to recreate the error. It happens on more than one computer. It never used to happen in IDCS2. It's not a missing font issue.
    I've tried recreating the InDesign preference files, but it didn't work. (See help file at http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400616&sliceId=1)
    Any suggestions would be hugely appreciated! This is slowing down my work a ton, and manually adding things like underline is killing me. If it persists, I'll have to roll back to CS2. :(

    We had exactly the same issue - but it only seemed to happen when a "Hyperlink" character style came in with the pasted text. In fact, the crash only happened when we tried to apply a paragraph style to a paragraph that had a hyperlink in it.
    Our solution: before we try to do anything else, we delete the "Hyperlink" character style. I can't guarantee that this will solve your issue, but it has worked for us (so far!) in those rare cases when we cut & paste Word text.
    We have never had this issue when we import ("Place") the Word file - that's generally a better workflow anyway.
    -Bill

  • Different paragraph styles within a text thread

    Does anybody know if it's possible to apply a different paragraph style to each text box in a text thread? I have three boxes: the first and the last have a small font and I'd like the middle one to have a larger font size.
    If it's not possible, is there an alternative way to do this?
    Thanks,
    Nacho

    Offhand i'd say that what Nacho wants to do will entail having separate text boxes...
    Seems to me that what he's doing is having the text flow from one box to another (column?). Obviously, changing / editing content will cause the text to shift its position.
    Nacho, i think you'll have to do one of the following:
    1/ Manually adjust the font style for the box you want each time you mke a correction
    or
    2/ Set up different, independent boxes (text areas) and style the box the way you want. Obviously changing text will mean changes in the area used by that box...
    Maybe someone else here can help out with a better suggestion...

  • How to Embed a Text Frame Within a Text Frame with Smart Text Reflow

    This is driving me nuts, and I've wasted hours searching exhaustively but can't seem to find the answer.
    I've been working with this indesign file and cleaning it up really well.  I now have all the text flowing with smart text reflow.  There are two parts in the book that have columns of information, or tables.  The way it was originally done was having a text box placed inside the text box.  But unfortunately, whenever you add pages before or after, the text box won't follow with the text box it is inside.  I have tried grouping the two text boxes together, but this doesn't seem to work with Smart Text Reflow (since every page is based on the primary master). How do you embed a text frame inside another text frame that is based off the primary master?  I guess it would be like using the text frame as an object. 
    I included an image to help my explanation.
    I even tried adding columns and then spannign the header part across, but this still doesn't flow with the rest of the text.

    ANchor it into the other text fram, look in the help file. Keyword = Anchored Objects.

  • TaggedText - how to apply while placing in text frame

    Hi there,
    I wonder how I can make use of TaggedText, which I have in a Javascript string (mixed, "normal" characters and TaggedText) to be placed in a layout text frame.
    Do I somehow have to switch on a TaggedText filter before placing my text and afterwards switching the filter off?
    Please help on!
    Thank you in advance,
    TYPO

    Hola Jongware!
    Thanx for the quick answer...
    I already suspected, that there's no easy way out of this, arghh!
    I think, I'll try it with an external lookup table (txt file), something like the following, after I have parsed the content of the story for start and end position:
    <tagA></tagA>             app.selection[0].parentStory.characters.itemByRange(start,end).fillColor = "Red";
    <tagB></tagB>               app.selection[0].parentStory.characters.itemByRange(start,end).fillColor  = "Green";
    Unfortunately this will slow down the whole process, switching the TaggedText filter on and off would have been much more effective... the heck with it.
    Thank you anyway,
    TYPO

  • How do I apply italics to any text between asterisk symbols and then have the asterisks removed?

    Please help!

    jocelynh32414240 wrote:
    Sorry - GREP is new. Like this? (\*)($2)(\*)? Not working for me.
    My workaround is to add another GREP style with a new character style with colour turned off called invisible, haha.
    As Peter mentioned, GREP styles cannot remove text, which is why he assumed you were using Find/Change.
    The "invisible" trick may still work for you, though. You need to set the text color to [None] but also set its size to 0.1 pt, which is as small as InDesign allows. A single character such as your '*' then is as invisible as possible.
    See http://indesignsecrets.com/using-grep-styles-to-format-html-code-in-indesign.php for a longer writeup, which uses the same trick to hide HTML.

  • How to create a child text frame within main text frame that flows as the text does

    Is there a way to create an anchored text frame that flows with the main text and goes on from the top of next column or page with the same type of horizontal alignment?
    I want to create a cuttable and paste-able, title, anchored small text frame and main text unit format that will repeat with different contents with as less manual labour as possible. (There is a simple example of what I am trying to achieve as a screenshot)
    Thanks in advance for any answer given

    One of the limitiations of anchored frames is that you cannot split them or include them in a text thread.

  • Data merging: how to get multiple records in single text frame?

    Hi
    I'm experimenting with data merging in InDesign CS3. The biggest stumbling block I've come across is trying to get my records to flow as continuous text in a single text frame (which would, ideally, autoflow onto new pages in the document). The records vary considerably in length, and so I can't just create a standard text frame to repeat on the page.
    Perhaps data merging isn't the best way of doing this and I should be learning to script instead. I feel like I'm just one step away, though.
    Any suggestions would be appreciated.

    OK, new scenario now:
    Is it possible to set a text box to auto-resize to fit the content that comes in during the data merge?
    I have placed one of my data fields in a text box with a stroke and fill, and placed this as an anchored object in the main text box with the other fields. The problem is that the length of text in this field varies considerably, and I'd like the text to fit snugly within its box. Ideally this text box would not appear at all if the field is blank for a particular record.
    I hope I've explained all of that clearly enough. Any ideas?

  • How do I create a series of text frames using values from Excel list?

    First of all, this is the very first script I'm attempting to write from scratch. I'm completely green at scripting, and I've picked up a few snippets from Adobe's ID scripting guide, but nothing has really stuck yet relating to this particular objective.
    My supervisor keeps a master list of ad spaces, with the name of the account, how wide the space is, and how tall the space is, all in an Excel sheet. These spaces can number in the hundreds, and I am stuck manually drawing one rectangle for every space, which takes a very long time.
    I'd like to create/have help creating a script that will take these values and "automagically" draw these spaces in the form of text frames, with the width (in columns) and the height (in inches) defined by the values in the master list, as well as the name of each account appearing in the subsequent text frames.
    The script doesn't necessarily need to be able to pull the values straight from the Excel sheet; I can transfer the values to a support text file if needed, or directly into the script, changing it as I need it. A big thing (if it is not able to pull right from an Excel sheet) is that the number of spaces changes weekly, and so do the accounts, and the width and the height. Accordingly, it would be ideal if the values from the sheet could be changed easily, so as to create a new set of spaces as needed.
    Positioning for each space is not crucial, only height and width. If they all appear on top of each other on the same page, that will be a result for me. The main idea is to not have to draw them all manually, one by one.
    To me, this sounds like a tall order, but hopefully some experienced scripters out there can assist me, as I wish to become experienced as well.
    So, the TL;DR version:
    - Script needs to draw a series of text frames.
    - Text frames dimensions need to be defined by width and height values from Excel sheet.
    - Text frames must have account name as contents (from account names in Excel sheet).
    - Accounts, width and height change every week in the Excel sheet, so must be relatively easy to exchange all of the values.
    - The width values are on the Excel sheet as columns. It would be ideal if the script could convert those numbers into multiples of columns as needed.
    - (Optional) Script can pull values directly from Excel sheet.
    - (Optional) Script can define text frame fill color as gray. (If it works as I think it will, I could just select all the resulting text frames myself and set them all to gray at once... I'm not that lazy )
    Thanks in advance to whomever can assist in any possible way, even if it is just a push in the right direction. This script will save 1-2 hours of tedium every week.

    Sound like the perfect thing for InDesign Scripting.
    I would copy the Excel contents into a text file, to get a format that is easily read from InDesign, and there will automatically be a TAB for each "cell" just using copy/paste.
    Here is a piece of code, that you perhaps could go on with (adding variable to change pages and location on page, and other stuff).
    The readFileLineByLine function, can be easily re-used with any function using "callback". You simply supply the function to it, that you want to be executed for every line of text that is read:
    const COLUMN_WIDTH = 2; // Define the column width in inch
    var pageIndex;
    var textFramesExported; // not implemented.
    // Add a new dokument. Set myDoc to app.activeDocument to use
    // the current document instead of creating a new one.
    var myDoc = app.documents.add();
    // The doSomethingWithTextRow function is called upon for every line of text read.
    readFileLineByLine('c:\\test.txt', doSomethingWithTextRow);
    function doSomethingWithTextRow(row){
        // We expect the text line to be TAB separated (\t = TAB). We get that from just copying the contents of an
        // excel file into a text document.
        var cells = row.split('\t');
        var companyName = cells[0]; // The Company name in the first slot of the array
        var width = COLUMN_WIDTH * cells[1];
        var height = cells[2];
        // Create a new text frame for every row handled
        if (pageIndex==undefined) pageIndex = 0; // Count up when you have exported a number of texts, I leave this for you to do.
        var newTextFrame = myDoc.pages[pageIndex].textFrames.add();
        newTextFrame.contents = companyName;
        // The text frame is created in the top left corner.
        newTextFrame.geometricBounds = [0, 0, height + ' in', width + ' in']; // Top, Left, Bottom, Right
        // You might want to move the textframes to other positions, keeping track of how many you put out per page.
        newTextFrame.move( [10, 10] );
    function readFileLineByLine(path, callbackFn){
        var myFileIn = new File(path);
        if (File.fs == 'Windows'){
            // This was probably added to recognize UTF-8 (even without its start marker?)
            myFileIn.encoding = 'UTF-8';
        myFileIn.open('r');
        var myEncoding = myFileIn.encoding;
        try{
            if (!myFileIn.exists){
                throw('Missing file: ' + myFileIn.fsName)
            var ln = '';
            while(!myFileIn.eof){
                // Read the lines from the file, until an empty line is found [now as a remark].
                ln = myFileIn.readln()
                // if(ln !='' && ln!='\n'){
                   // Call the function supplied as argument
                   callbackFn(ln);
        }catch(e){
            alert(e);
            gCancel = true;
        finally{
            myFileIn.close();
    The file in C:\ in my example was saved as UTF-8 and looks like this (showing hidden characters):
    Message was edited by: Andreas Jansson

  • How do I create a series of text frames from a list of files?

    And I'm back again.
    This time, I'm wondering how I can use JavaScript to place a series of text frames from a list of files, preferably with the ability to specify criteria before running the script.
    Here's the details: I work for a newspaper and I lay out stories for the pages (in addition to the other part of my job, laying out ad spaces, as detailed in a previous thread, for which I requested another script, thanks Andreas and Jongware ). The file names for the stories are labeled for the section they go in, like L- for Life, C- for Comment, S- for Sports, etc.
    I'd like to create a script that asks for a criteria in a text box (where I can type L-, C-, S- or whatever else I need) and then places all of the stories, in a specified directory, whose file names match what was typed in the box, one text frame for each.
    I can't rightly tell if this is a simpler or more difficult script to write out, but I plan on putting research into it as usual so I can develop it myself. However, I figured it would be more efficient to ask first, then research, so that while I'm researching, I can refer to the opinions of my fellow forumites, and/or the mods.
    Thanks again for any assistance offered.

    And I'm back again.
    This time, I'm wondering how I can use JavaScript to place a series of text frames from a list of files, preferably with the ability to specify criteria before running the script.
    Here's the details: I work for a newspaper and I lay out stories for the pages (in addition to the other part of my job, laying out ad spaces, as detailed in a previous thread, for which I requested another script, thanks Andreas and Jongware ). The file names for the stories are labeled for the section they go in, like L- for Life, C- for Comment, S- for Sports, etc.
    I'd like to create a script that asks for a criteria in a text box (where I can type L-, C-, S- or whatever else I need) and then places all of the stories, in a specified directory, whose file names match what was typed in the box, one text frame for each.
    I can't rightly tell if this is a simpler or more difficult script to write out, but I plan on putting research into it as usual so I can develop it myself. However, I figured it would be more efficient to ask first, then research, so that while I'm researching, I can refer to the opinions of my fellow forumites, and/or the mods.
    Thanks again for any assistance offered.

Maybe you are looking for

  • How can I pass a value from the datagrid to my textinput

    Hi i am new in adobe flex! I have only one row in my datagrid and it has 5 dataField. Those dataFields are id, ln, fn, kurs, yr. I want to pass those value into a textinput respectively. Heres my code: <mx:DataGrid x="396" y="10" width="110" height="

  • Migrate the users, groups from essbase 7.1.6 to shared services

    Hi Our current production is essbase version 7.1.6 and we are planning to migrate to EPM 11.1.2 . We would like to move the security administration from Essbase to Shared Services (want to use Native Directory). can somebody please suggest 1) An util

  • Unable to get lineseries to render

    I'm attempting to add a line series to a  column chart that renders fine. But the line series won't render. I created a line chart without the column chart using the exact same dataprovider and the linechart renders just fine <mx:ColumnChart id="slaC

  • Two IPods in household

    I bought an IPod last year and plan on giving that one to my son.  I will buy the new 4th generation now.  Do we have to have separate accounts on iTunes?  Or can we have same music/apps as we paid for all together.

  • Change from my Verizon pre-paid monthly to 2 year contarct with a second line

    I currently have a pre-paid monthly plan plus extra 30 GB data for my iPad2. I want to switch to a 2 year contract with 2 lines and 2 phones, one of the phones I want to keep my old Verison number. Is this doable?