Script of the current paragraph style

Can someone tell me what is the code to return the paragraph style for the current position of the cursor.

Also I can I ask something to the current paragraph is not using paragraph styles.

For example, what would be the code to "make the current text of paragraph Red.

Help would be much appreciated as we see questions that I'm a complete Newbie in scripting.

if (app.documents.length > 0 && app.selection.length === 1 && app.selection[0].hasOwnProperty("baseline")) {
     // return the paragraph style for the current cursor position
     alert("Paragraph style: " + app.selection[0].appliedParagraphStyle.name);
     // Make current paragraph text Red (the 1st paragraph in the selection)
     app.selection[0].paragraphs[0].fillColor = "C=15 M=100 Y=100 K=0";
}

Tags: InDesign

Similar Questions

  • script to duplicate the standard paragraph style, and then change the size of the character point

    I want to create a script that will create a cascade of paragraph based on the style settings [standard paragraph] styles. My goal is to point size of each new paragraph style character as a percentage of the original [standard paragraph]. So if [standard paragraph] is 100% (point character size 10pt), the script would create a paragraph style called 120% ' that has a point size of character of 12 points. Then 133%, 140%, and on and on. I modified a script found on this forum to generate these new styles, but I don't know how to be based on the [standard paragraph]. Any help would be much appreciated, thanks in advance.

    current script:

    var doc = app.activeDocument,

    pStyle = ['100% ', '120% ', '133% '];

    for (var i = 0; i < pstyle.length; i ++)

    {

    If (pstyle [i] is "100 %")

    {

    doc.paragraphStyles.add ({name: pstyle [i], appliedFont: 'Deer', pointSize:10});})

    }

    ElseIf (pstyle [i] == "120 %")

    {

    doc.paragraphStyles.add ({name: pstyle [i], appliedFont: "Deer", pointSize:10 * 1,2})

    }

    ElseIf (pstyle [i] == "133 %")

    {

    doc.paragraphStyles.add ({name: pstyle [i], appliedFont: "Deer", pointSize:10 * 1.33333})

    }

    }

    Try this,

    var doc = app.activeDocument,
        pstyle = ["100%", "120%", "133%" ];
    
    for(var i =0;i
    

    Kind regards

    Cognet

  • Problem affecting the existing paragraph style

    Hi all!

    I have searched all morning and can't find a lot of good documentation on the use of existing scripts paragraph styles to HAVE. I know that you can build a live, but more specifically, I want to add in the tabs and don't see this as an option to add paragraph styles in one of the refs to javascript.

    I do an "export log" that captures the version, date, time, artist name/layers assigned to help our team of quality control. My problem is that any new text added to the box ignores existing paragraph styles, and I do not see so he can apply what I have in the file.

    I can find the style, so I don't know it exists, and I can also draw the text box, so I think that these paths are correct and working, it's just the applyTo seemingly does not. Here is my code below:

    //get the textBox with the sign off content
    exportLogText = docRef.textFrames.getByName("RT_Signoff");
    //add the sign off text
    exportLogText.contents += "v. " + versionLetter + "\t" + theDate + "\t" + timeStamp + "\tExport by: " + username + "\tLayers: " + layersExported;
    exportLogText.contents += "\r"
    //identify the "Export_Log" paragraph style that already exists in the AI doc
    var paraStyle = docRef.paragraphStyles.getByName("Export_Log");
    for (ps = 0; ps < exportLogText.paragraphs.length; ps++){
        paraStyle.applyTo(exportLogText.paragraphs[ps], true);
    }
    redraw();
    
    

    Once it hits the applyTo line, the script stops. I found similar posts claiming this code should work, so I don't know what I'm missing! Any help is appreciated.

    I found a similar code here:a paragraph style for blocks of text in the document

    It's really a matter of aesthetics, but I can't stand the text to look like this:

    issue1.PNG

    When he could look like this!

    issue2.PNG

    Looks like it was a problem with my file which was causing the anomaly, not the script. Things seem to be working now! Thanks for the input guys!

  • Find and replace all occurrences of a string within the current paragraph.

    I did so much work, and it's my last method to implement.

    I want to get the current active doc the current paragraph and replace all occurrences of a string inside this paragraph with another string.

    For example, say I have the following paragraph in a document:

    «This is a sentence that.» This is another sentence. It is also another sentence. The sentence ".

    If the user opens the document containing the paragraph and goes to this paragraph by clicking in any place in there, I want to replace e.g.g "another punishment" with "phrase.

    But only in the current active paragraph in the active document.

    I found a code with F_ApiFind and F_ApiGetTextRange to get the current text selection, but I can't think of a way to do it.

    Post edited by: Efstathios Chatzikyriakidis

    Problem solved people. Thank you.

  • How can I get the current paragraph?

    I want to get the current paragraph where the insertion point is.

    How can I do this in FDK?

    Ch,

    I can answer some of these questions, but if you have decided that this thread is replied, please give credit to Mike.

    About the audit for a FO_Pgf object, you shouldn't have that. I think that there is some obscure cases where F_ApiGetTextRange() gives you an object that is not a paragraph... I forgot exactly but I think it has to with a text graphic subject line or something like that. I could be wrong. In any case, if you have a stream of regular text with an insertion point, you will get a paragraph object.

    This line will abort the operation if any text is selected. Do you really want that?

    If (insertionPoint.beg.objId! = insertionPoint.end.objId)

    This line will abort the operation if several paragraphs are selected. Do you really want that? Without this verification, you will always get the text of the first selected paragraph.

    If (insertionPoint.beg.offset! = insertionPoint.end.offset)

    Otherwise, the code looks OK to me, at least regarding the FDK calls. You have problems with him?

    Russ

  • Why can't define paragraph ball in the standard paragraph style?

    I want to configure my standard paragraph style so that I can quickly apply the individual paragraphs balls - using MY favorite dashes - without having to create a new style to the paragraphs of the ball. I tried to change the settings of the standard paragraph, with no document open style, but he doesn't seem to accept my choice of dashes. First of all, I selected bullets and put a dash, but then the default paragraph with bullets. When I pass the ball setting back to "none" the only thing he keeps is the last setting that I chose for the tabs. (At the same time, which changes the default tab for all paragraphs setting.) But when I create a new doct and start a paragraph of the ball, the hyphens by default always a.25 /-.25 and any tab setting LOWER a.25 results in the updated first line indented for the tab setting, but the rest of the paragraph indented a.25. There seems to be no way to change default indentation for bullets without creating a new paragraph style. And usually I'm fine with that. But I thought that I would have a default Quick using the standard paragraph style. Am I missing something or is it just not possible?

    Here is a Visual/verbal screenshot to help explain:

    InDesign-Bullet-Problem.png

    Let's see if I understand differently from others. You want to apply bullets manually from time to time without having to select a new style, you would do this by pressing the button bulleted list in the Control Panel, and you want the settings for tabs and indents, other than the default. Is this correct?

    Far as I can tell there is no way to do it. You cannot configure the settings for the chips unless the text cursor is active or if you set a style, there is no way to set up the new default values. You don't want to not set parameters whenever you need a ball, then either you type the balls by hand, tab and insert a hyphen character here, which is actually a lot more work, or you go ahead and set up the style. You can access the list of style in the menu drop-down control panel, or you can add a keyboard shortcut to give you quick access, or press Ctrl (Cmd on Mac) + entry for quick access to apply and start typing the name of the style (almost as fast as a keyboard shortcut).

  • Remove based on the substituted paragraph style attributes

    Is there a way to clear the attributes that you put in a "based on" paragraph style, on the part of start by resetting to the base?

    For example:

    • 1 a paragraph style track set to + 10.
    • You create 2 of paragraph 1-based Style and made several substitutions, including change tracking to + 5.
    • Now you realize you want the two styles have the same follow-up and you want to experiment with this setting.

    How can you erase what has been entered in the Style 2, so that any changes made to the Style 1 applies to the 2 Style once again? I realize that it is possible with character styles, but after scouring the net, I think that this should not be possible with paragraph styles.

    Am I wrong? If this is not the case, why it should not be possible?

    Thank you.

    Go to the 2 paragraph style definition and reset the traking to the same value as the base style. It becomes as well as watt do you the basic style. Only the attributes that are different are locked.

  • Script for Indesign find paragraph style change at the table with the table style

    Hello

    I hope someone could help me with a script.

    I can tab with a paragraph style and I want to convert that to a table with a table style.

    Kind regards

    Patrick

    Yes

    My problem is solved

    Thank you very much.

    Patrick

  • use Image catalog script for the current document

    Is it possible to use the script to image catalogue for the current document in which we work instead of leaving the mark of script a new document fees for placed images?

    use,

    //ImageCatalog.jsx
    //An InDesign CS6 JavaScript
    /*
    @@@BUILDINFO@@@ "ImageCatalog.jsx" 3.0.0 15 December 2009
    */
    //Creates an image catalog from the graphic files in a selected folder.
    //Each file can be labeled with the file name, and the labels are placed on
    //a separate layer and formatted using a paragraph style ("label") you can
    //modify to change the appearance of the labels.
    //
    //For more information on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html
    //Or visit the InDesign Scripting User to User forum at http://www.adobeforums.com .
    //
    //The myExtensions array contains the extensions of the graphic file types you want
    //to include in the catalog. You can remove extensions from or add extensions to this list.
    //myExtensions is a global. Mac OS users should also look at the file types in the myFileFilter function.
    main();
    function main(){
      var myFilteredFiles;
      //Make certain that user interaction (display of dialogs, etc.) is turned on.
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
      myExtensions = [".jpg", ".jpeg", ".eps", ".ps", ".pdf", ".tif", ".tiff", ".gif", ".psd", ".ai"]
      //Display the folder browser.
      var myFolder = Folder.selectDialog("Select the folder containing the images", "");
      //Get the path to the folder containing the files you want to place.
      if(myFolder != null){
      if(File.fs == "Macintosh"){
      myFilteredFiles = myMacOSFileFilter(myFolder);
      }
      else{
      myFilteredFiles = myWinOSFileFilter(myFolder);
      }
      if(myFilteredFiles.length != 0){
      myDisplayDialog(myFilteredFiles, myFolder);
      alert("Done!");
      }
      }
    }
    //Windows version of the file filter.
    function myWinOSFileFilter(myFolder){
      var myFiles = new Array;
      var myFilteredFiles = new Array;
      for(myExtensionCounter = 0; myExtensionCounter < myExtensions.length; myExtensionCounter++){
      myExtension = myExtensions[myExtensionCounter];
            myFiles = myFolder.getFiles("*"+ myExtension);
      if(myFiles.length != 0){
      for(var myFileCounter = 0; myFileCounter < myFiles.length; myFileCounter++){
      myFilteredFiles.push(myFiles[myFileCounter]);
      }
      }
      }
      return myFilteredFiles;
    }
    function myMacOSFileFilter(myFolder){
      var myFilteredFiles = myFolder.getFiles(myFileFilter);
      return myFilteredFiles;
    }
    //Mac OS version of file filter
    //Have to provide a separate version because not all Mac OS users use file extensions
    //and/or file extensions are sometimes hidden by the Finder.
    function myFileFilter(myFile){
      var myFileType = myFile.type;
      switch (myFileType){
      case "JPEG":
      case "EPSF":
      case "PICT":
      case "TIFF":
      case "8BPS":
      case "GIFf":
      case "PDF ":
      return true;
      break;
      default:
      for(var myCounter = 0; myCounter-1){
      return true;
      break;
      }
      }
      }
      return false;
    }
    function myDisplayDialog(myFiles, myFolder){
      var myLabelWidth = 112;
      var myStyleNames = myGetParagraphStyleNames(app);
      var myLayerNames = ["Layer 1", "Labels"];
      var myDialog = app.dialogs.add({name:"Image Catalog"});
      with(myDialog.dialogColumns.add()){
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Information:"});
      }
      with(borderPanels.add()){
      with(dialogColumns.add()){
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Source Folder:", minWidth:myLabelWidth});
      staticTexts.add({staticLabel:myFolder.path + "/" + myFolder.name});
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Number of Images:", minWidth:myLabelWidth});
      staticTexts.add({staticLabel:myFiles.length + ""});
      }
      }
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Options:"});
      }
      with(borderPanels.add()){
      with(dialogColumns.add()){
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Number of Rows:", minWidth:myLabelWidth});
      var myNumberOfRowsField = integerEditboxes.add({editValue:3});
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Number of Columns:", minWidth:myLabelWidth});
      var myNumberOfColumnsField = integerEditboxes.add({editValue:3});
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Horizontal Offset:", minWidth:myLabelWidth});
      var myHorizontalOffsetField = measurementEditboxes.add({editValue:12, editUnits:MeasurementUnits.points});
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Vertical Offset:", minWidth:myLabelWidth});
      var myVerticalOffsetField = measurementEditboxes.add({editValue:24, editUnits:MeasurementUnits.points});
      }
      with (dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Fitting:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myFitProportionalCheckbox = checkboxControls.add({staticLabel:"Proportional", checkedState:true});
      var myFitCenterContentCheckbox = checkboxControls.add({staticLabel:"Center Content", checkedState:true});
      var myFitFrameToContentCheckbox = checkboxControls.add({staticLabel:"Frame to Content", checkedState:true});
      }
      }
      with(dialogRows.add()){
      var myRemoveEmptyFramesCheckbox = checkboxControls.add({staticLabel:"Remove Empty Frames:", checkedState:true});
      }
      }
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:""});
      }
      var myLabelsGroup = enablingGroups.add({staticLabel:"Labels", checkedState:true});
      with (myLabelsGroup){
      with(dialogColumns.add()){
      //Label type
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Type:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelTypeDropdown = dropdowns.add({stringList:["File name", "File path", "XMP description", "XMP author"], selectedIndex:0});
      }
      }
      //Text frame height
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Height:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelHeightField = measurementEditboxes.add({editValue:24, editUnits:MeasurementUnits.points});
      }
      }
      //Text frame offset
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Offset:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelOffsetField = measurementEditboxes.add({editValue:0, editUnits:MeasurementUnits.points});
      }
      }
      //Style to apply
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Style:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelStyleDropdown = dropdowns.add({stringList:myStyleNames, selectedIndex:0});
      }
      }
      //Layer
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Layer:", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLayerDropdown = dropdowns.add({stringList:myLayerNames, selectedIndex:0});
      }
      }
      }
      }
            var myResult = myDialog.show();
            if(myResult == true){
      var myNumberOfRows = myNumberOfRowsField.editValue;
      var myNumberOfColumns = myNumberOfColumnsField.editValue;
      var myRemoveEmptyFrames = myRemoveEmptyFramesCheckbox.checkedState;
      var myFitProportional = myFitProportionalCheckbox.checkedState;
      var myFitCenterContent = myFitCenterContentCheckbox.checkedState;
      var myFitFrameToContent = myFitFrameToContentCheckbox.checkedState;
      var myHorizontalOffset = myHorizontalOffsetField.editValue;
      var myVerticalOffset = myVerticalOffsetField.editValue;
      var myMakeLabels = myLabelsGroup.checkedState;
      var myLabelType = myLabelTypeDropdown.selectedIndex;
      var myLabelHeight = myLabelHeightField.editValue;
      var myLabelOffset = myLabelOffsetField.editValue;
      var myLabelStyle = myStyleNames[myLabelStyleDropdown.selectedIndex];
      var myLayerName = myLayerNames[myLayerDropdown.selectedIndex];
      myDialog.destroy();
      myMakeImageCatalog(myFiles, myNumberOfRows, myNumberOfColumns, myRemoveEmptyFrames, myFitProportional, myFitCenterContent, myFitFrameToContent, myHorizontalOffset, myVerticalOffset, myMakeLabels, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle,  myLayerName);
            }
      else{
      myDialog.destroy();
      }
      }
    }
    function myGetParagraphStyleNames(myDocument){
      var myStyleNames = new Array;
      var myAddLabelStyle = true;
      for(var myCounter = 0; myCounter < myDocument.paragraphStyles.length; myCounter++){
      myStyleNames.push(myDocument.paragraphStyles.item(myCounter).name);
      if (myDocument.paragraphStyles.item(myCounter).name == "Labels"){
      myAddLabelStyle = false;
      }
      }
      if(myAddLabelStyle == true){
      myStyleNames.push("Labels");
      }
      return myStyleNames;
    }
    function myMakeImageCatalog(myFiles, myNumberOfRows, myNumberOfColumns, myRemoveEmptyFrames, myFitProportional, myFitCenterContent, myFitFrameToContent, myHorizontalOffset, myVerticalOffset, myMakeLabels, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle,  myLayerName){
      var myPage, myFile, myCounter, myX1, myY1, myX2, myY2, myRectangle, myLabelStyle, myLabelLayer;
      var myParagraphStyle, myError;
      var myFramesPerPage = myNumberOfRows * myNumberOfColumns;
      var myDocument = app.activeDocument;
      myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
      myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
      var myDocumentPreferences = myDocument.documentPreferences;
      var myNumberOfFrames = myFiles.length;
      var myNumberOfPages = Math.round(myNumberOfFrames / myFramesPerPage);
      if ((myNumberOfPages * myFramesPerPage) < myNumberOfFrames){
      myNumberOfPages++;
      }
      //If myMakeLabels is true, then add the label style and layer if they do not already exist.
      if(myMakeLabels == true){
      try{
      myLabelLayer = myDocument.layers.item(myLayerName);
      //if the layer does not exist, trying to get the layer name will cause an error.
      myLabelLayer.name;
      }
      catch (myError){
      myLabelLayer = myDocument.layers.add({name:myLayerName});
      }
      //If the paragraph style does not exist, create it.
      try{
      myParagraphStyle = myDocument.paragraphStyles.item(myLabelStyle);
      myParagraphStyle.name;
      }
      catch(myError){
      myDocument.paragraphStyles.add({name:myLabelStyle});
      }
      }
      myDocumentPreferences.pagesPerDocument = myNumberOfPages;
      myDocumentPreferences.facingPages = false;
      var myPage = myDocument.pages.item(0);
      var myMarginPreferences = myPage.marginPreferences;
      var myLeftMargin = myMarginPreferences.left;
      var myTopMargin = myMarginPreferences.top;
      var myRightMargin = myMarginPreferences.right;
      var myBottomMargin = myMarginPreferences.bottom;
      var myLiveWidth = (myDocumentPreferences.pageWidth - (myLeftMargin + myRightMargin)) + myHorizontalOffset
      var myLiveHeight = myDocumentPreferences.pageHeight - (myTopMargin + myBottomMargin)
      var myColumnWidth = myLiveWidth / myNumberOfColumns
      var myFrameWidth = myColumnWidth - myHorizontalOffset
      var myRowHeight = (myLiveHeight / myNumberOfRows)
      var myFrameHeight = myRowHeight - myVerticalOffset
      var myPages = myDocument.pages;
      // Construct the frames in reverse order. Don't laugh--this will
      // save us time later (when we place the graphics).
      for (myCounter = myDocument.pages.length-1; myCounter >= 0; myCounter--){
      myPage = myPages.item(myCounter);
      for (var myRowCounter = myNumberOfRows; myRowCounter >= 1; myRowCounter--){
      myY1 = myTopMargin + (myRowHeight * (myRowCounter-1));
      myY2 = myY1 + myFrameHeight;
      for (var myColumnCounter = myNumberOfColumns; myColumnCounter >= 1; myColumnCounter--){
      myX1 = myLeftMargin + (myColumnWidth * (myColumnCounter-1));
      myX2 = myX1 + myFrameWidth;
      myRectangle = myPage.rectangles.add(myDocument.layers.item(-1), undefined, undefined, {geometricBounds:[myY1, myX1, myY2, myX2], strokeWeight:0, strokeColor:myDocument.swatches.item("None")});
      }
      }
      }
      // Because we constructed the frames in reverse order, rectangle 1
      // is the first rectangle on page 1, so we can simply iterate through
      // the rectangles, placing a file in each one in turn. myFiles = myFolder.Files;
      for (myCounter = 0; myCounter < myNumberOfFrames; myCounter++){
      myFile = myFiles[myCounter];
      myRectangle = myDocument.rectangles.item(myCounter);
      myRectangle.place(File(myFile));
      myRectangle.label = myFile.fsName.toString();
      //Apply fitting options as specified.
      if(myFitProportional){
      myRectangle.fit(FitOptions.proportionally);
      }
      if(myFitCenterContent){
      myRectangle.fit(FitOptions.centerContent);
      }
      if(myFitFrameToContent){
      myRectangle.fit(FitOptions.frameToContent);
      }
      //Add the label, if necessary.
      if(myMakeLabels == true){
      myAddLabel(myRectangle, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle, myLayerName);
      }
      }
      if (myRemoveEmptyFrames == 1){
      for (var myCounter = myDocument.rectangles.length-1; myCounter >= 0;myCounter--){
      if (myDocument.rectangles.item(myCounter).contentType == ContentType.unassigned){
      myDocument.rectangles.item(myCounter).remove();
      }
      else{
      //As soon as you encounter a rectangle with content, exit the loop.
      break;
      }
      }
      }
    }
    //Function that adds the label.
    function myAddLabel(myFrame, myLabelType, myLabelHeight, myLabelOffset, myLabelStyleName, myLayerName){
      var myDocument = app.documents.item(0);
      var myLabel;
      var myLabelStyle = myDocument.paragraphStyles.item(myLabelStyleName);
      var myLabelLayer = myDocument.layers.item(myLayerName);
      var myLink =myFrame.graphics.item(0).itemLink;
      //Label type defines the text that goes in the label.
      switch(myLabelType){
      //File name
      case 0:
      myLabel = myLink.name;
      break;
      //File path
      case 1:
      myLabel = myLink.filePath;
      break;
      //XMP description
      case 2:
      try{
      myLabel = myLink.linkXmp.description;
      if(myLabel.replace(/^\s*$/gi, "")==""){
      throw myError;
      }
      }
      catch(myError){
      myLabel = "No description available.";
      }
      break;
      //XMP author
      case 3:
      try{
      myLabel = myLink.linkXmp.author
      if(myLabel.replace(/^\s*$/gi, "")==""){
      throw myError;
      }
      }
      catch(myError){
      myLabel = "No author available.";
      }
      break;
      }
      var myX1 = myFrame.geometricBounds[1];
      var myY1 = myFrame.geometricBounds[2] + myLabelOffset;
      var myX2 = myFrame.geometricBounds[3];
      var myY2 = myY1 + myLabelHeight;
      var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel});
      myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;
      myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;
    }
    
  • Change the paragraphs found in the standard paragraph style?

    I have look here for about an hour and could not find a discussion for this.  I see where it clears the substitutions but not change Style all together.  Here's what I need help do.  If I left saying text 4 selected boxes, I want the power to change the standard paragraph to paragraph and character set to None style style. If there is already can a discussion that I missed in this regard you point me in that direction.  If this is not the case, can I please help with this.

    You can usetpk1982of script to change all the paragraphs of the standard paragraph. But if you only want the block of selected text, then you will need to adjust thescript to change paragraph styles in the selected text frames.

    basically replace line 2 by var allTFrames = app.selection;
    Also, if you need to clear character styles need to do before you change the paragraph style or character styles will be removed and the formatting will be left as a local override.  Your final script after that these changes would be:

    myDoc var = app.activeDocument;

    var myTFrames = app.selection;

    for (var i = 0; i)< mytframes.length;="" i++)="">

    var tFrame = myTFrames [i];

    pStory var = tFrame.parentStory;

    var allParas = pStory.paragraphs.everyItem ();

    pStory.characters.everyItem () .appliedCharacterStyle = app.activeDocument.characterStyles [0];

    allParas.appliedParagraphStyle = app.activeDocument.paragraphStyles [1];

    }

    Note: instead of simply replacing the 2 wire I also changed the name of the variable to reflect rather than leave it in the form allTFrames; and add line 7... Other than these two changes everything was the script of tpk1982

  • script to replace a paragraph style with a different styles, both within a folder

    I am trying to write a script that will remove a paragraph style or character and then replace it with another paragraph or character style, both are in a folder within these groups of style. I have tried so many different scripts and that you have not found the right combination to work.

    any help would be greatly appreciated! Thank you!

    To target a paragraph style that is in a folder, you will have to tunnel to him through groups of styles, thus:

    Style1 = app.activeDocument.paragraphStyleGroups.itemByName("Group1").paragraphStyleGroups.itemByN ame("Group2").paragraphStyles.itemByName ("myParagraphStyle");

    Then find the second style (one you want to replace by):

    Style2 = app.activeDocument.paragraphStyleGroups.itemByName("GroupA").paragraphStyles.itemByName ("AnotherParaStyle");

    Simple and then remove the first style, replace it with the second:

    Style1.Remove (Style2);

    HTH,

    Ariel

  • Count the unused paragraph styles

    I want to check InDesign documents my students to see if they have been neatly with their style sheets. I have a script that works partially (I think this would work in CS4, if you replace CS4 CS5).

    The bit that does not try to save the styles within groups. I commented in the script to display the error section. I get the error:

    "Invalid value for the set property" applied paragraph style". "Planned to string, the style section or anything, but will put \"body text (body). " "number 30477

    I tried to put the name of the style and the group, because that's how it works if you do it manually, IE body text (body). But it does not work.

    Any help would be appreciated.

    property myTypeReport: ' " - makes available anywhere.
    " game of myTypeReport to '" - prevents report becomes cumulative when running several times.
    Tell application "Adobe InDesign CS5"
    the value myDocument to rating 1
    game of unusedStyles to "'
    game of myFoundItems to "'

    game myDescription to "unused paragraph styles"
    the value myParagraphStyleGroups for each paragraph style group of myDocument
    the value myParagraphStyles for each paragraph style of myDocument

    Repeat with I have a 3 in (County of myParagraphStyles)
    define myStyle to the the point i of myParagraphStyles name
    the value find text preferences for Nothing
    the value text preferences to change anything
    the value applied paragraph style to find text preferences to myStyle
    tell myDocument
    the value myFoundItems to find text
    if (account myFoundItems) = 0 then the value unusedStyles to (unusedStyles + 1).
    end say
    end Repeat

    -This is the section of the error
    Repeat with x 1 to the number of myParagraphStyleGroups
    set myGroup to the of the point x of myParagraphStyleGroups name
    the value myParagraphStyles for this entire paragraph styles to paragraph style group myGroup of myDocument
    Repeat with I have from 1 to (count of myParagraphStyles)


    game of myStyle to (name of point i of myParagraphStyles) & "(" & myGroup & "") " string "
    -Returns the myStyle
    the value find text preferences for Nothing
    the value text preferences to change anything
    the value applied paragraph style to find text preferences to myStyle
    tell myDocument
    the value myFoundItems to find text
    if (account myFoundItems) = 0 then the value unusedStyles to (unusedStyles + 1).
    end say
    end Repeat
    end Repeat
    -finish the section error

    "myReport game to "(" & unusedStyles & "")" " & "\t\t" & myDescription
    if (County unusedStyles) > 0 then the value myTypeReport to myTypeReport & myReport and return
    return myTypeReport
    end say

    Can you make best use of all styles of paragraph in your document instead of styles of paragraph of the document, which should access the independent styles of groups? You would have to give on the name using as reference (probably a good thing anyway) and use the style itself (in your find/replace).

  • Locate and replace the last paragraph style

    With .js or grep, I want to change the style of the last paragraph ball against one with more space after, there are a lot of them in one story mixed with other styles.

    Change this:

    • B. blarrblarr (bullet style)
    • B. b. b. b. (bullet style)
    • B. b. change it (bullet style)

    To do this:

    • B. blarrblarr (bullet style)
    • B. b. b. b. (bullet style)
    • B. b. change this (last bullet style)

    Is this possible? If anyone can help would be great!

    Thank you very much!

    I think that this JavaScript does the job. You may need to change the style names to match yours. In addition, it assumes that the styles are not grouped in a folder.

    //DESCRIPTION: Fix last bullet paragraphs
    
    (function() {
         if (app.documents.length > 0) {
              findFixLastBullets(app.documents[0]);
         }
         function findFixLastBullets(aDoc) {
              setupFindText();
              app.findTextPreferences.appliedParagraphStyle =  "Bullet";
              var myFinds = aDoc.findText();
              for (var j = myFinds.length - 1; j >= 0; j--) {
                  var lastPara = myFinds[j].paragraphs[-1];
                  // if next para already BulletLast do nothing
                  var nextPara = lastPara.insertionPoints[-1].paragraphs[0];
                  if (nextPara.appliedParagraphStyle.name == "BulletLast") continue;
                  lastPara.appliedParagraphStyle = "BulletLast";
              }
         }
         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
    
    }())
    

    Note the small touch that if the next paragraph is already BulletLast, it ignores who found the text. This allows you to run the script more than once if you add more text.

    Dave

  • (JS) How to apply the existing paragraph styles to text in a textFrame

    @I have a definition called "Header" in my Document.

    How to apply this paragraph style "Header" textFrame selected with the text "This is my head" using JS

    Please advise...

    Thank you..

    @I have a definition called "Header" in my Document.

    How to apply this paragraph style "Header" in textFrame selected with the text "This is my head" using JS

    as directed by your initial thread in question that asked you to change only the text block selected, so I gave code such as

    myDoc1 = app.selection [0];

    but myDoc1 = app.activeDocument; lets you apply the styleforwholedocument

    FYI

  • How clear the text paragraph styles imported from the word?

    I am trying to create a user manual and I use a model that has its own set up paragraph styles.

    I use InDesign CS6 because I use the PDF2ID of Markzware plugin that I bought for this version. I used it to bring in the instructions of the users who have made their work in Word and saved in PDF format.

    I just want to take their work and re - format to match the styles of paragraphs in the model. But when I select the text and choose a new paragraph style, it does not change.

    I tried to use the button 'Clear the replacements' but nothing happens.

    I found a site that offers to use keyboard shortcuts to clear the formatting, but they no longer work.

    What Miss me?

    PDF don't know anything about styles. The plugin could have done a few "intelligently" all styles, based on the formatting, but I don't know if he is capable of that because I've never used.

    Hold Shift + Alt\Opt click a paragraph style should apply this style and remove character styles as well as local formatting overrides.

Maybe you are looking for

  • Not possible to start after recovery

    Hello Yesterday my Toshiba Satellite L555-110 is not stopped correctly. It looked like endless loop, while Win 7 (64 bit) showed "logout". I turned the laptop off (5 sec power button). After that, Windows is not started anymore. There was a black wit

  • Is there a Toshiba laptop like this one?

    Sorry for posting in the section of Satellite.I really don't know what would be the ideal sub-forum to ask the following question. I was always a fan of Toshiba hardware. The architecture is superb.I had two laptops and a multimedia projector serve m

  • How to read the multiple slave devices in a RTU modbus RS485 2-wire network without changing slave address manually?

    Hello Currently, I can read data out of multiple using the attached VI DAQ devices by manually changing the address of the slave on the front panel that determines what slave to read the data. However, I want the VI to do it automatically for me inst

  • Pavilion g4 - 1303au: processor upgrade

    Mr President.I want to change my processor i3 processor intel. It is possible. If yes then tell me CPU Model No. And what I change when upgrading processor.

  • Unable to save picture as a jeg - only png or bitmap

    Hello I tried to save some pictures from my email to my computer. However, as well as expansion of files 2 (.png and .bmp) options. I can't save it in jpeg format. I saved photos in the past as recently as November and had no problem. I deleted my te