Replace paragraph style [JS]

Hi All,
(1)
I have a JS code for replace paragraph style (come word file (floppy style)) its working good. But my problem is that when run this code if find paragraph style not define (word file (floppy style)) in flow indesign file then error. Is that possible if paragraph style not find then ignore then run next step. Please see code below
var myDocument = app.activeDocument;
var myParagraphStyleA = myDocument.paragraphStyles.item("h1");
myParagraphStyleA.remove(myDocument.paragraphStyles.item("1H: One Head"));
(2)
You have any script for delete only unused  (para/char (Floppy style)) only.
Thank you so much adv.
regard
snegig

Hello Sir (Harbs, Jongware and other),
I am really sorry for late answering. I am junior so heavy workload.
This line code "h1" paragraph style actually comes ms-word file (floppy style).
var myParagraphStyleA = myDocument.paragraphStyles.item("h1");
Second line code "1H: One Head" is InDesign CS4 paragraph style.
var myParagraphStyleA = myDocument.paragraphStyles.item("h1");
If "h1" PS comes (ms-word) in InDesign then code run good. In case if "h1" PS not comes in InDesign file then script error.
I have just mapping both Paragraph Style (PS) (ms-word, InDesign) if both styles mapping then script run. When run same script other chapters if any tag not come form (ms-word) but whose PS define in script then script error.
My question is that if any PS comes from (ms-word) if this style not define in script, script run properly otherwise script display massage these PS (ms-word(floppy)) not define in your script code.
(2) My second query
If all PS mapping by script but ms-word style (floppy) appear in my indesign file. Is that possible these PS replace (mapping) ms-word style (floppy) automatically remove.
Thank you so much
Regard
snegig

Similar Messages

  • Find and replace paragraph style

    I am creating a javascript for InDesign in order to search and replace some text. The text I am looking for has to be in a certain Paragraph style.
    This is what I have so far:
    app.findTextPreferences = app.changeTextPreferences = null;
    app.findTextPreferences.findWhat = '^p'
    app.changeTextPreferences.changeTo = ';'
    app.activeDocument.changeText();
    I need to find/change a return of a certain paragraph style to a semi colon. What is the script that I would use to search for paragraph style?

    try:
    app.findTextPreferences.appliedParagraphStyle = 'para style';
    If you want to replace the para style, use:
    app.changeTextPreferences.appliedParagraphStyle = 'new para style'

  • How to replace a paragraph style with object style

    Hi,
    I am having this issue lately that in paginating a newspaper I have to do all premium post with a Rectangle Border. the problem is that the text is in the grid.
    Is there anyway that, while I add a specific paragraph style to some parts of the text, I can automatically give this text a specific Object Style (like stroke rectangle)
    Does it make sense?
    Thank you very much

    Michael,
    I think that I did not explain myself as I should have. The problem is not really related to links but more of a automatic replacement issue.
    Every time I do this newspaper I include a new text information and the location of the Headers changes in every single case.
    http://i.imgur.com/sgQ2wIK.jpg
    In the link, the blue paragraphs need to be replaced with the respective Header Icons that you see on top and everytime this location of the headers in the newspaper changes due to the different number of posts in each specific category. Now the problem is related on how to autoaticaly replace this string in blue with its respective header
    thanks a lot in advace for all your help

  • How do I edit a paragraph style in Muse?

    Is there a way to change a typeface or other detail in a paragraph stylesheet in Muse? I've tried duplicating the style, and then, when I delete the old one, I replace it with the new one. Is there a more direct way to do that?

    Hello,
    If you create a paragraph style, then change any attribute, the style has an override. If you'd like to keep this override and redefine the style click the "redefine selected style from attributes" button (highlighted in the screen shot.)
    More info is here:
    http://helpx.adobe.com/muse/using/creating-using-character-paragraph-styles.html

  • How can I force a paragraph style without losing italic?

    This has been annoying me for ages. I work on documents in Word, applying italic to book titles etc, and then import into indesign. I apply a paragraph style and three times out of four the bits of italic are preserved. However, the fourth time the paragraph style doesn't take (probably because of the presence of italic) and I have to force it to do so by using Alt-click. Invariably the italic is then replaced by roman.
    It's happening just now with a whole lot of footnotes and endnotes in a book I'm working on and means I have to go back through them all, manually applying italic to my book titles and references. Is there any way to force an endnote/footnote paragraph style without losing the italic text?
    Thanks for any suggestions,
    Tom.

    I'm not sure that forward planning is so necessary here.
    If your only concern is losing italics when importing from Word, create,
    in InDesign, an italic character style. Then do a search and replace
    throughout the InDesign document (after you've placed the Word file)
    searching for italics formatting, and replacing with your italics
    character style.
    That will prevent you from losing your italics formatting.
    Repeat for bold, bold italics, superscript, subscript, and anything else
    the author uses.
    There are some scripts that help in this process (I think one of them is
    called "preptext", by Jongware).
    If you want a comprehensive solution that can find every type of
    formatting override and creates and applies the appropriate character
    style, check out my "Create Character Styles from Overrides" script,
    available under the scripting tab on freelancebookdesign.com.
    Ariel

  • Is it possible to have an anchored object linked to a paragraph style?

    I want to link an anchored object to a paragraph style, so that whenever a paragraph that has a particular style is created, an anchored object is created at the same time. The particular application is to label the associate text with the anchored object. is this possible?

    Here an example for a GREP search/replace:
    Search for the beginning of every paragraph + the first character:
    ^(.)
    Replace with the formatted contents of the clipboard + the found character:
    ~C$1
    Uwe

  • [AS] How to change a paragraph style within any folder in Find Grep?

    I want to change both text and paragraph style
    I do that job very easily until I put paragraph styles in a folder
    How to express the paragraph style "passage" within the folder "1st" in AppleScript?
    In line 18 below, "1st:passage" may be wrong... so I've tried and search for an hour, but I can't get the answer..
    sorry for bad english
    my main()
    on main()
      mySnippet_test()
      myTeardown()
    end main
    on mySnippet_test()
              tell application "Adobe InDesign CS5.5"
                        set myDocument to document 1
                        set find grep preferences to nothing
                        set change grep preferences to nothing
                        set include footnotes of find change grep options to false
                        set include hidden layers of find change grep options to false
                        set include locked layers for find of find change grep options to false
                        set include locked stories for find of find change grep options to false
                        set include master pages of find change grep options to false
                        set find what of find grep preferences to "\\n"
                        set change to of change grep preferences to "\\r"
                        set applied paragraph style of change grep preferences to "1st:passage"
                        tell myDocument
      change grep
                        end tell
      --Clear the find/change preferences after the search.
                        set find grep preferences to nothing
                        set change grep preferences to nothing
              end tell
    end mySnippet_test
    on myTeardown()
    end myTeardown

    Replace the red line with… Replacing name strings to yours…
    set myStyle to paragraph style "Style A" of paragraph style group "Style Group 1" of myDocument
    set applied paragraph style of change grep preferences to myStyle

  • How can you create a paragraph style that removes all spaces and forces everything to lower case?

    Hi,
    Is there anyway of using GREP (or some other magical wizardry) to create a paragraph style that automatically removes all spaces and forces words into lower case?
    Strange request i know....I'm wanting to use it for datamerged email addresses.
    Thanks

    so doing it through InDesign is a work around I'm exploring.
    Excel has the 'LOWER' function and the ability to record macros for a quick find/replace on the spaces - so that's definitely a good option if it can't be solved purely in InDesign.
    You can change case via scripting in InDesign. This AppleScript (OSX only) will set the case of the selected paragraph style to lower. It would be possible to add some code that would strip spaces as well:
    tell application "Adobe InDesign CS6"
        activate
            set StyleList to name of every paragraph style of active document
        set myDialog to make dialog with properties {name:"Document Paragraph Styles"}
        tell myDialog
            tell (make dialog column)
                tell (make border panel)
                    tell (make dialog column)
                        make static text with properties {static label:"Choose a Style", min width:150}
                    end tell
                    tell (make dialog column)
                        set myPresetsDropdown to make dropdown with properties {string list:StyleList, selected index:0, min width:150}
                    end tell
                end tell
            end tell
        end tell
        set myResult to show myDialog
        if myResult = true then
            --+1 gets the correct name because list starts at 0
            set myStyle to item ((selected index of myPresetsDropdown) + 1) of StyleList
        else
            return
        end if
        destroy myDialog
        tell active document
            set myStyle to paragraph style myStyle
            repeat with j from 1 to (count stories)
                repeat with i from 1 to (count paragraphs in story j)
                    if applied paragraph style of paragraph i of story j is myStyle then
                        --defines a variable to replace the generic this_text parameter in the handler
                        set SCText to the contents of paragraph i of story j
                        set contents of paragraph i of story j to my change_case_of(SCText)
                    end if
                end repeat
            end repeat
        end tell
    end tell
    on change_case_of(this_text)
        set the_comparison_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        set the_source_string to "abcdefghijklmnopqrstuvwxyz"
        set the_new_text to ""
        repeat with thisChar in this_text
            set x to the offset of thisChar in the_comparison_string
            if x is not 0 then
                set the_new_text to (the_new_text & character x of the_source_string) as string
            else
                set the_new_text to (the_new_text & thisChar) as string
            end if
        end repeat
        return the_new_text
    end change_case_of

  • Need to add a carriage return in Paragraph styles

    Hi. I am in a muddle. I have a large amount of data from an xml source. I need to quickly add carriage returns appropriately throughout it so that the paragraph styles can be differentiated.I am using tags manually mapped to styles to do this.
    In order to carriage returns am I right in thinking that I can add a GREP style to each para style, and that it will sense the end of the para through the end marker position of each tag? If this is so, what would the GREP expressionlook like to that I can automate locating the end of a tag/para style so that I can add ~b to it?
    Gratefully!

    Hi @chantal_diva arts,
    It seems to be difficult, because you have much more invinsible character than only the xml markers in your document.
    I think one good way could be @obi-wan Kenobis way.
    Perhaps you can upload an example idml on a file hoster of your choise (e.g. xup.in).
    Regardless, you can try the following:
    1. text search:
    <FEFF>
    replace with:
    2. grep search:
    (?<=\b##)(.)
    replace with:
    \r$1
    3. clean document
    grep search:
    #+
    replace with:
    (nothing)  an empty replace field
    Have fun

  • [JS CS3] Find/Change "[Basic Paragraph]" style

    I'm trying to find all occurances of the [Basic Paragraph] style and replace them with [No Paragraph Style]. I'm using:
    app.findTextPreferences.appliedParagraphStyle = "[Basic Paragraph Style]";
    app.changeTextPreferences.appliedParagraphStyle = "[No Paragraph Style]";
    I get the message "Invalid value for set property 'appliedParagraphStyle'. Expected String, ParagraphStyle or NothingEnum enumerator, but received "[Basic Paragraph Style]"."
    I've tried every combination of brackets, no brackets, quotes, no quotes, etc. It doesn't seem like this can be scripted, even though it can be done via find/change in InDesign. Am I banging my head against the wall? Does anyone know if this can be done?

    "[Basic Paragraph]" as shown in the code below doesn't work either. (the word "Style" actually snuck in as I was trying different variations. But no combination seems to work.
    If anyone knows that [Basic Paragraph] can or cannot be accessed via scripting, I'd like to know. Thanks.
    app.findTextPreferences.appliedParagraphStyle = "[Basic Paragraph]";
    app.changeTextPreferences.appliedParagraphStyle = "[No Paragraph Style]";

  • Image in paragraph style?

    I use CS3 - Windows XP
    Hello
    I am publishing a photobook in several languages, and before I start description of each photograph I need to put in the flag of the corresponding language. Kind of like a drop cap.
    I was wondering if there is some way to automate this process using styles, because at the moment I am just putting a tiny graphics frame with the flag image (GIF) in front of the corresponding text, making the text flow around it , which is quite tedious work (there is like 200+ photos and it seems like there will be 8 languages)
    I was wondering if it is possible to place an image into a paragraph style in some way, or incorporate the image as a bullet, or something like that.
    Thank you

    you can add some "tag" as flag description in text:
    [DE] hdf shkdjhfkjhskdjh fk skdhfk
    [BG] khsd kjfhkds f ds
    [PL] kjdh kajs hk ask dkas
    next you can use script to replace these "tags" with images
    or you can use Find/Replace and search for "[DE]" and replace with clipboard "~C" (of course without ")
    robin
    www.adobescripts.com

  • How to change paragraph style

    I have a text frame selected and it contains a story having various pargraph styles applied.
    I want to get name of each paragraph style applied in it and replace each with some other styles.
    But when I am applying style only one style is applied to whole text frame .(i.e all existing styles are replaced with a single style).
    Please help me , if there is any way.
    Thanks

    It was not a criticism of your design choices. You have misread my comments, I am simply warning you from long experience. We have no idea of what you do or don't know, most people who come here have little and it is safer to assume they have none.
    Creating a Textbox, which is randomly sized and placed and contains no text, is not dissimilar to having a Textbox already in the document with Placeholder text in it that you click on and it is replaced by whatever you type. If your client is quite familiar with Pages they must be familiar with using Placeholders and with duplicating and resizing objects as required. It is just a way of getting around your problem.
    Obviously you have done something else, or you would not be getting the results you have. I keep my version of Pages 5.5.3 as installed for testing, I don't know what you have done that is different and can't tell without having the file.
    If you want me to look, email me via my blue name. If not, that's fine too.
    Peter

  • Anchoring Object to a Paragraph Style? Objects behind text

    Hello,
    I am trying to anchor an graphic object to a paragraph style that is a numbered paragraph.  I have set up my numbering and I want a single graphic to be anchored to the number so it appears behind the number each time I choose that paragrah style.
    Is this possible to do?
    Or perhaps I should ask how other people put graphics behind bullets or numbers and have them anchor to the text...
    I sure could use soem help with this; it seems like it should be easy...
    Dave.

    I found this intriguing, so I thought I'd see what I could come up with.
    I made a numbered paragraph style, to start. Then I made a Cyan filled ellipse, which I anchored in front of the first word in one of the paragraphs, and changed the positioning to custom and made sure it was relative to the anchor, and turned off keep within frame boundaries, to allow me to position it "behind" the number. As emmanuel points out, anchored objects are actually in front of the text, so so far it's not working.
    I selected the ellipse and changed it's blend mode to multiply. This will not change it's color where it is over white, but it will darken wherever it is on top of another color, creating a rich black number, for example, if you used black text. Looks pretty good now.
    Select the ellipse and create a new object style based on it. This will by default include the blend mode and anchored object parameters, and be sure the style is applied to the selected ellipse. Now cut the ellipse and paste it on the pastboard out of the way so you don't lose it.
    As long as the object is on the clipboard you can use it for a find/change operation, so you can do that now, or later, just by copying it again when it's convenient. The find/change needs to be a GREP search for ^(.) which means find any character at the beginning of a paragraph, and replace with ~c$1 which means replace with the formatted contents of the clipboard and the found character. Be sure to set the find formatting options to the numbered paragraph style.
    Because you gave the object an object style that includes the blend mode and positioning, and you pasted it as a formatted object, those attributes are preserved and the graphic will be positioned correctly for each paragraph.
    Peter

  • Does deleting paragraph styles affect documents which used a deleted style?

    Assume you have a web page or site made with paragraph styles.
    You start a new page in that site but decide to delete a bunch of paragraph styles which you  no longer want
    The style should be in the html of the earlier documents and deleting the style should not delete the existing HTML.
    But with Muse you never can be sure.
    So is it ok to clean up the clutter and delete a bunch of old styles when creating something new or not?
    Please do not respond unless you actually know the answer. No guesses please.

    Hi Jkijki,
    If you have created a paragraph style and applied to a paragraph, when you try to delete that paragraph style you will get option to replace the paragraph styling with another style (if there exist any):
    Check this link: http://prntscr.com/3p9c5x
    Regards,
    Gaurav Aggarwal

  • [win][js][cs4]find/change paragraph styles without losing local overrides

    Hi guys i need a little help here.
    I created a javascript which will find and replace doc file paragraph styles with indesign paragraph styles. everything works fine but the problem is that when it applies the paragraph styles it loses all local overrides. i tried:
    changetext(false);
    but its not working is there some kind of conditional parameter that i can put in the changetext() function so that it wont clear local overrides?
    Thanks.
    CharlesD

    Thanks Kasyan. You're always there to save my day. Thank you very much...
    I slightly modify the script to go through all my paragraph styles that need to be replaced coz there are hundreds of them. Im not sure though if this is the best or is there any faster way to do this:
    replace("T1", "Text", "T1");
    replace("T", "Text", "T");
    replace("1", "Heads", "1");
    replace("2", "Heads", "2");
    function replace(input, folder, output) {
        var foundItem;   
        var doc = app.activeDocument;
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
        app.findGrepPreferences.findWhat = ".+";
        app.findGrepPreferences.appliedParagraphStyle = input;
        var foundItems = doc.findGrep();
        for (var i = 0; i < foundItems.length; i++) {
            foundItem = foundItems[i];
            foundItem.applyParagraphStyle(doc.paragraphStyleGroups.item(folder).paragraphStyles.item( output), false);
        app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

Maybe you are looking for

  • Cannot delete two stubborn video files

    Hello all, I have two files that I have downloaded by accident from a p2p site. They are both .mkv files, which I believe makes them Matroska video files. They are trailers for movies. They appear to work fine in VLC, but when I delete them and empty

  • Need query to fetch single record

    I am having table t1 with below data c1 c2 1   10 2   10 when I am using below query  select max(c2) from t1 group by c1 I am geeting both the records. How can i fetch only record (any one) ?

  • Website doesn't show, after successful upload to ftp host

    I'm using muse v7 and my domain is www.fifacafe.com on Godaddy, when I publish on businesscatalyst.com the website is ok, but when I upload to ftp server it says successful but the website is totally empty

  • Oracle8i EE (8.1.5) vs. Oracle OAS (4.0.7)

    I have a "Oracle JDeveloper Suite 2.0 Free 30-Day Evaluation Copy for Window NT" CD set which I am testing to see if we could use it as out Enterprise Java Bean server platform. I have earlier tried Oracle 8 (NOT i) and OAS 4.? but had big problems w

  • Converting byte[] to unicode , help needed.

    need help, folks. i need to convert byte[] to unicode in byte[] form say i already loaded bunch of data byte[] bytes = {........} //bunch array of bytesand i read in the bytes as a stream in the native form. ByteArrayInputStream stream = new ByteArra