[AS][CS3] Finding text with character style

Please help to tell me how to find text with a specific character style and then delete the text.
I had no problem doing this with CS2 but its doing my head in now.
Thanks,
Andrew

Here you go. This assumes that your character style is at the top level of the panel. If you're using style groups, you'll need to write code to get at the style you want to use.
//DESCRIPTION: Delete text in named character style
(function() {
  if (app.documents.length > 0) {
    deleteStyledText(app.documents[0]);
  function deleteStyledText(aDoc) {
    var cStyle = aDoc.characterStyles.item("CharStyleName");
    setupFindText();
    app.findTextPreferences.appliedCharacterStyle = cStyle;
    aDoc.changeText();
  function setupFindText(find, change, wholeWd, caseSense, foots, hidLayers, lockedLayers, lockedStories, masters) {
    app.findTextPreferences = null;
    app.changeTextPreferences = null;
    try { app.findTextPreferences.findWhat = find } catch(e) {};
    try {app.changeTextPreferences.changeTo = change } catch(e) {};
    app.findChangeTextOptions.properties = {
      caseSensitive:(caseSense == null ? false : caseSense),
      wholeWord:(wholeWd == null ? false : wholeWd),
      includeFootnotes:(foots == null ? false : foots),
      includeHiddenLayers:(hidLayers == null ? false : hidLayers),
      includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
      includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
      includeMasterPages:(masters == null ? false : masters)
  } // end setupFindText
Dave

Similar Messages

  • Conditional build tags with character styles and ignored text

    RoboHelp HTML v8.0.2.208
    Windows XP Professional Version 2002 Service Pack 3 with 2 GB of RAM
    Output: WebHelp and HTML Help
    I have recently moved my projects from RH HTML X5 to RH HTML 8 and this is when the following problem appeared. I use lots of conditional build tags within the help projects. Some of these tags are for my own use for reference and I combine these with character styles containing a coloured background (highlight) so that they show up in the WebHelp or HTML Help output (e.g. text to identify the software version that the field/feature/text was added, reminders to check details, insertion of bug ID numbers, design document names, etc.). These areas of text are stripped out of the final build for customers by using a conditional build expression.
    What I have noticed is that if a paragraph contains text with a conditional build tag applied AND that tagged text has a character style applied AND an unknown word within the conditional build tag is ignored (with the HTML tag <?rh-ignored text="word_to_be_ignored" ?>), saving the topic, closing it, then re-opening it shows that the conditional build text has stretched to the next conditional build tag, or to the end of the topic if there aren’t any other conditional build tags. This also happens by switching from Design View to HTML View. Note that this doesn’t happen if Ignore All is applied to the unknown word.
    This doesn’t just apply to projects converted from RH X5. I created a new test project in RH8 and the same behaviour was observed. Similar behaviour occurred very occasionally in RH X5 but that seemed to be down to HTML tags being nested incorrectly.
    The largest project contains around 1200 topics and with many hundreds of conditional build text areas this now causes a problem. I’ll probably have to locate every ignored word in an area of conditional text within each project, set it to Ignore All and then manually remove and re-apply the conditional build tags, unless someone can come up with something clever. Can anyone else replicate this and should it be logged as a bug?

    Hi Daggins,
    Thanks - that is good info to have. But as we all agree, that does take away from the point of single-sourcing.
    You aren't misunderstsanding exactly... I am doing all my conditional tagging in FM and it works like a charm in terms of the PDFs that I generate from FM, and even the conditionally tagged text in RH shows/hides correctly. The issue is I am also importing my index and TOC from FM... and even if I have an entire file in FM tagged as conditional (all the text is tagged as conditional, I don't know if you can tag a file as conditional), the file name as a heading it still appears in the RH TOC. There is no text... but in my view it shouldn't appear in the TOC either (it looks like just a broken link when I generate my online help) - this is not ideal.

  • Working with Character Styles in Photoshop CC

    Hi,
    I upgraded to Photoshop CC and was quite excited about the Character Styles Panel. But now, I'm completely puzzled.
    It almost looks like Adobe didn't finish the feature before shipping 14.1.2
    1. I can't reorder the character list? Why use a different list implementation than that for "Layer Comps?"
    2. I want to copy and paste a character style from one selection to another (Basically the workflow from Apple Keynote). It should be possible with character styles, but it just didn't work:
      - I select a formatted text section
       - I press "New Character Style icon"
       - I double-click the new style -> The font-size in the style differs from the font-size of the orginal selection?!
       - I'm pretty sure it has to do with style of the original text not being directly overwritten from "None", but there is no feature to "bake" style-formatting either.
    3. I can't remove and restyle the Character-Style "None". But when I accidently assign "None", it is defined as 12px Arial Black . So the default-style HAS a style definition and should therefore be editable like the other character styles.
    I'm completely blow away how non-intuitive the whole process is. I never had problems to understand character styles in InDesign, Pages, Word and Illustrator. But in Photoshop is either completely broken or non-intuitive.
    Just my two cents.
    tom

    Your sure your using photoshop cc on windows vista?
    I was under the impression that photoshop cc would not even install on windows vista.
    What version of camera raw do you have?
    In photoshop under Help>About Plugin does it list Camera Raw and if so which version is it?
    (click on the words Camera Raw to see the version)
    Camera raw doesn't work if it's a camera raw file or some other file type such as jpeg or tif?
    What camera are the camera raw files from?
    Officially camera raw 8.3 is the latest version of camera raw that will work on windows vista.

  • Having a problem with character styles in indesign

    I'm having another problem with my style sheets in indesign, I've now got an awful lot of styles in paragraph and character styles. I've created different styles for paragraph justified text and when I go to my style in paragraph styles to use tight text copy, character styles always overides it so it means I have to do  whole lot of extra formatting just to put it right. Does anyone have an idea how I can stop character styles overiding paragraph styles? Thanks very much.

    Perhaps your character styles apply more than you actually want? I.e., rather than just "+Italic" it also applies custom tracking. You should use character styles only to override the stuff you really want to change.
    You can check by calling up the definition for those character styles; the huge "Style Settings" text box lists all the attributes it changes.

  • Pretagging text with ID styles without using XML tags

    I just wanna pretag some text with ID styles, such that when I place the text, it joins the layout already formatted.
    But how? Can I do this without drinking from the XML cup?
    Thx.

    Many thanks for your reply.<br /><br />When I export tagged copy (either verbose or abbreviated methods), the resulting text document is complex -- all kinds of coding. Yet, when placed back into ID, it appears correctly formatted.<br /><br />But my attempts to pretag new text with, say, <ParaStyle:New subsubcat> (one of the exported tags), brings in the tag itself, not correctly formatted new text. What to do?<br /><br />I was unable to locate the PDF document about tagged text that you referenced. My upgrades are downloads, not discs.<br />Any further suggestions on where to find the PDF document.<br /><br />Thanks again.

  • Find texts with more than one Character Style applied

    Hi,
    If you need to find - and replace/restyle - texts where more than one Character Style is applied - here is tool for you - for ID CS3 and ID CS4:
    http://www.adobescripts.com/search.php?query=multi+findreplace+grep&action=results
    You can define options for up to 8 characters - by using GREP expressions.
    Script is only for PC platform.
    robin
    www.adobescripts.com

    Never tried with bullets but nested styles might work... I think you can chain two or more nested style, and then you can define first nested style to effect only first character, second nested style to next character and so on....

  • [CS3 JS] Correcting a Character Style Anomaly

    It used to be that you could define a character style to merely colour the text and give it an underline (e.g. for Hyperlinks) or just superscript the text (for Reference citations). When such styles, which do not call for a particular font or font size, are placed into InDesign CS, the styled text would take on the font and font size of the underlying paragraph style. However, after placing a Word .doc with these styles into a CS2 template, the font and font size becomes Times New Roman and 10 pt. The solution was to save an .rtf file and re-import the text. Now, in CS3 this work-around doesnt quite work: the font is okay, but the font size reverts to that default size of 10 pt.
    So, I would like a script that finds all occurrences of two specific character styles (Hyperlink and bibref) and then corrects the font size of the found text to that of the underlying paragraph style. These styles can appear anywhere within a document, including in tables. I have trawled through this forum and found enough to be able to search for the character styles, but I cannot fathom how to apply the font size of the underlying paragraph style. Any help will be greatly appreciated.
    By the way, re-applying the character styles doesnt work because the character styles dont define the font size; also clearing the overrides on the paragraph style while the text is selected isnt a viable solution, because other local formatting (i.e. italic) would be lost.

    Hi Peter
    Thank you very much for your quick response. I tried your script and it did as you intended by clearing the Font, Font Style and Point Size in the character style, but unfortunately it did not correct the problem of the style becoming some default style and size (Times New Roman 10 pt) when placed into ID.
    In fact, I had already set up the 'bibref' and 'Hyperlink' character styles with these fields blanked out. Also, I made Adobe aware of this bug when CS2 came out and they warned me that CS3 wouldn't fix the problem; but I didn't realize that CS3 would be worse than CS2 so that using an rtf file wouldn't fix things.
    So, I am left with my initial query: is it possible to write a script to search for the character styles in question and apply the font size of the underlying paragraph style?
    Thanks a lot for any help you can give.

  • Finding MANUALLY applied character styles

    Hi all,
    We're in the process of switching to an XML workflow, and as one of our interim steps we're applying tags to paragraph and character styles in some of our documents. I'm aware of the option to map styles to tags and this should work well for paragraph styles. However, we're looking for a way to only map the character styles that have been manually applied.
    As an example, we have a paragraph style for instructions that has a bold number nested at the beginning of each paragraph. In other places, the same character style may be used to bold a specific word, but it is applied manually. Is it possible to map to tags ONLY the character styles that were applied manually? We do not want tags identifying character styles that were applied via Nested Styles or GREP Styles.
    I am assuming this would take some sort of script, which is why I'm posting in the scripting forum. Does anyone know if this is possible?
    Thanks in advance,
    Matthew

    Another InDesign oddity!
    If you fill a frame full of placeholder text and assign a "Bold" character style to, for example, a Nested Style:1 word, and a GREP style \<\w{4,6}\>, then use regular (or GREP) Find Text to search for the character style, it'll only highlight words that are at the start of the paragraph. Now that is wrong, wrong, wrong, because
    (a) it should not find any of them -- if you click your cursor into one of these bolded words, the Character Style panel says it's [None].
    or
    (b) it should find all of them, not just those that happen to be at the start of a paragraph. (BTW -- it's not the Nested Style it picks up; when using only GREP styles it'll also find words-at-the-start).
    It is funny, if things like this tickle you, that in a script "findText" works exactly the same. However: if you 'found' bold text and then interrogate what character style it has applied, it will only return your "bold" style if it was applied manually.
    See this script -- test with a placeholder text, aforementioned Nested/GREP styles, and a few hand-picked words that you applied "bold" to yourself. It will only report the ones you marked.
    app.findTextPreferences = null;
    app.findTextPreferences.appliedCharacterStyle = "bold";
    list = app.activeDocument.findText();
    r = [];
    while (list.length)
         next = list.pop();
         if (next.appliedCharacterStyle == app.activeDocument.characterStyles.item("bold"))
              r.push (next.contents);
    alert (r.join("\r"));

  • Placing Word File with Character Styles

    InDesign CS5, windows 7
    I am hoping for some guidance.
    I am creating a directory from an Excel file.  This is what I have done and where I am at.
    1. Edited Excel File to ad "Headers" for Name, Address, etc...
    2. Used Mail Merge in MS word to create a Directory.
         - Created Character Styles in word for different fields.
         - Did some minor editing to remove stray spaces, etc...
    3. Placed wrod file in InDesign.  Layout is created with basic text boxes that are split into 4 columns, each box linked to the next (I have about 30 pages of this).
    At first, this was working OK, but the CHaracter styles were not coming through (Actually, they were lost during the merge in Word).  So, I did some work and found that there was a code I could add to the Merge Fields oin Word to force the Character styles to be retained.
    Anyway, I did that.  However, now when I place the Word File in InDesign, it appears to hang at "Processing Character Styles".
    I removed the code from the merge, figuring I could go back, but I still get that hang.
    Any suggestions are appreciated...
    -kaz

    Any suggestions are appreciated...
    I think I followed most of your explanation. But, since we can't see what you're doing, it's hard to know 100% what your reasons are for doing what you do. F'rinstance, I wonder why you're bothering with the Word merge at all. Without knowing why you have to run the merge in Word, I'd suggest this:
    add headers to your Excel file
    save out .csv
    Use InDesign's Data Merge tool, skip Word entirely
    Why do you need to use Word's Mail Merge? If you've never used Data Merge in ID, you should probably take a look at the Help file entry to see if it will work for you.

  • Get Text with Applied Style

    Hi all,
    I am using InDesign CS3 on OS 10.5. I'm trying to write something in Applescript that can look at a document and give me the text that has a certain applied style.
    For example, if a document contained the text "Hello, world" and had an applied paragraph style called "Greeting," then what I want is to use my script to tell that document something like this:
    tell application "Adobe Indesign CS3"
    set theDoc to document 1
    set theText to get every paragraph of theDoc whose applied paragraph style is "Greeting"
    end tell
    theText
    -->should return: "Hello, world"
    Obviously, I tried that script, but it doesn't work. I get the error "Adobe InDesign CS3 got an error: Cant get every paragraph of document "MyDocument.indd" whose applied paragraph style = "Greeting"."
    I'm not sure if I am just using the wrong commands or what. Any help is greatly appreciated!

    Hi Hayden,
    The trouble is, theDoc doesn't have paragraphs. If you open the InDesign dictionary and look at the document object, you'll see text frames, and you'll see stories, but no paragraphs. To get all of the paragraphs, you'd use something like this:
    set theText to every paragraph of every story
    But getting every paragraph of every story whose applied paragraph style is a specific style is harder to do using a filter ("whose") clause, because it has multiple conditions. Shane can probably do it, but I'm not having much luck. All the same, why bother? InDesign has a perfectly good find text method that will do what you want. Something like this:
    tell application "Adobe InDesign CS3"
    --Clear the find text preferences
    set find text preferences to nothing
    set applied paragraph style of find text preferences to paragraph style "Greeting" of document 1
    tell document 1
    set myFoundItems to find text
    end tell
    end tell
    Thanks,
    Ole

  • Generating TOC with Character Styles Referenced

    I have a paragraph style applied so several paragraphs in a document.  This paragraph style has a nested style for the first few words of the paragraph which also have a specific character style assigned to them.  The thing is that I need to be able to reference or list these first few in my TOC.  I'm aware that the automatically generated TOC doesn't have the ability to refrence character styles, but I'm hoping that someone else knows of a way around this.  Does anyone know how to work around that or include, somehow, character styles in the TOC list?  The main reason I'm needing to do this is because the automaticly generated TOC (Layout > Table of Content) is built in such a way that it can be recognized in the settings when exporting to epub.

    It was a good idea and almost worked.  I created an extra textbox with the text I wanted included in that text box with a specific paragraph style applied to it that has non-printing text.  Once I included the paragraph style in the Automatically generated TOC it worked in generating the text in the TOC line up, but when I exported the file to an EPUB there was no way to tell it not to include the text that where non-printing.  Therefore the words/sentences that were not visible in indesign or on print and anchored to the original text were doubled in the final epub version.

  • Save as SVG, with character styles included as CSS classes? (CC)

    Hi, I know that
    a) Character styles in Illustrator CC are saved as CSS classes in the CSS properties menu, with appropriate style info;
    b) These classes can be exported to a CSS file from the CSS properties manual;
    c) Graphic styles can also be saved as CSS classes; but
    d) When saving to SVG (with Style Elements option) the graphic style classes are included in the SVG code, but NOT the character style classes. Instead, it uses classes like ".st0", ".st1", etc., which separate each styled attribute (font-family, size, etc.) into its own class.
    Is there any way around this problem, short of extensively editing the svg code by hand later? The end result we're looking for is an SVG where text has classes assigned, based on character styles.  (Ideally we'd then link to an external style sheet in order to modify based on the end use of the SVG. So for example a graphic with .textBold and .textRegular, where those classes are later assigned different values based on the delivery device.)
    Has anyone else dealt with this issue?
    Thanks!

    Hi Ianmcarey,
    Thanks for the detailed Explanation. We will investigate this Requirement of Exporting Character style classes in the SVG code.
    Thanks and Regards,
    Mohit Gupta.

  • Text variable & character style

    Is it possible to make a character style part of the definition of a text variable?

    I see the problem, can't think of anything off-hand... Your idea
    Find/Change could be used to search for a variable
    has its own set of limitation. Other than you'd expect, Find/Change cannot search for any variable of choice -- rather, you can only distinguish between the different types of variables. If your product name is a Custom Text variable, the Find/Change will work but it will pick up all custom text vars.
    Yes, still plenty room for improvements

  • Export/import text with all styles (indesign CS3 (XP SP2))

    I'm looking for the best way to export text so authors can edit their text using MS Word, Excel or xml. (they don't want to use Indesign). after they are done editting I want to import the text back into Indesign (with par, char, obj styles).
    I know how to import/export to .doc with styles, but this doesn't work for table, object styles, and page breaks.
    Xml tags or plugin/software might be a solution.
    I've searched the forums, google and read the help file, but still don't know what the best/quickest solution might be. ... ?
    thanks in advance

    1. Those programs don't support every feaature of InDesign, so you are out of luck.
    2. If they don't want to use InDesign, ask them to use InCopy, that is the only one programm which supports the whole InDesgin-functionlity
    3. Page breaks should never be done manually, never in Word, neither with InDesign. They should be created via paragraph styles in both program, but with the import options is a checker to get Word's page breaks.

  • CS3 - pasting text with registration/trademark - not converting in code.

    Hey Gang,
    In my previous versions of DW.
    As I copy and paste content from a PSD or any other document
    into DW design
    view, that has a character such as a Registration symbol,
    Trademark,
    Copyright etc.
    DW would automatically write the proper code in thec ode view
    (such as
    &reg;).
    That is no longer happening with CS3.
    It is actually placing a small reg, or copywrite symbol into
    the code itself
    (which is not rendering correctly in some browser / email
    client
    environments.
    I can't find a setting to correct this behaviour. Have I
    overlooked a
    preference setting?
    Thanks
    -D

    Hi Dave,
    I was having a hard time with that too, the code kept showing
    up instead of the symbol. Since you're using CS3 if you go to the
    text tab, the very last option on the right has a bunch of
    different options, it has the tm and registration symbol. If that
    doesn't work you could always go into your system tools and
    character map and then copy and paste it into your page, that
    actually worked for me as well, but the first way is better! :)
    Good luck!
    -Amanda

Maybe you are looking for