7 Replies Latest reply on Feb 12, 2016 8:31 AM by tpk1982

    Paste with formatting from word file

    tpk1982 Level 4

      Hi,

       

      I doing copy and paste of texts from word file to Indesign. I need to keep all italic, bold etc.

       

      My logic is :

       

      1) Enable the Clipboard Handling as shown below

      Screen Shot 2016-02-12 at 3.02.58 PM.png

       

      2) Assign cmd+v to execute my script in keyboard shortcuts.

      Screen Shot 2016-02-12 at 3.04.24 PM.png

       

      3) So when i press cmd+v it executes the script.

       

      4) Below is the sample code i tried. In my Document i already have 'Bold' character style in style group.

       

      app.menuActions.item("$ID/Paste").invoke(); //assigned cmd+v as shortcut 
      var myDoc=app.activeDocument;  
      app.findTextPreferences = null;     app.changeTextPreferences = null;  
      app.findTextPreferences.fontStyle="Bold";
      app.changeTextPreferences.appliedCharacterStyle=myDoc.characterStyleGroups.itemByName("General").characterStyles.item("Bold");
      app.changeText();  
      
      
      //app.menuActions.item("$ID/Clear Overrides").invoke();
      

       

       

      It doing as expected. My requirement is:

       

      1) I need to override my paragraph style.

       

      2) I used app, so the script running slowly. How i can do it better fastly.

       

      I saw others script to creating paragraph styles but i am trying to create script my own logic.

       

      Thanks,

      Karthi

        • 1. Re: Paste with formatting from word file
          LeoMari Level 2

          You can import the word file with enabled options import show and to map styles. Bold and word Italico should be done with character style in Word. So they can also be mapped in Indesign.

          Screen Shot 2016-02-12 at 8.49.19 AM.png

          • 2. Re: Paste with formatting from word file
            tpk1982 Level 4

            Hi Leo,

             

            Thanks for your response.

             

            My requirement is copying and pasting from word file. Not Importing. Because i need to update some content in my indesign file based on new word document.

             

            Regards,

            Karthi

            • 3. Re: Paste with formatting from word file
              LeoMari Level 2

              Try for Grep, follows a code that I have used to replace ordinal:

               

                      app.findGrepPreferences = NothingEnum.nothing;

                      app.changeGrepPreferences = NothingEnum.nothing;

                            

                      app.findChangeGrepOptions.includeFootnotes = true;

                      app.findChangeGrepOptions.includeHiddenLayers = true;

                      app.findChangeGrepOptions.includeLockedLayersForFind = true

                      app.findChangeGrepOptions.includeLockedStoriesForFind = true;

                      app.findChangeGrepOptions.includeMasterPages = true;  

                    

                      app.findGrepPreferences.findWhat = "o";

                      app.findGrepPreferences.appliedParagraphStyle = "•00_titulo_unidade_2_CV";

                      app.findGrepPreferences.underline  = true;

                      app.findGrepPreferences.position = Position.SUPERSCRIPT;

                      app.changeGrepPreferences.changeTo = "º";

                      //app.changeGrepPreferences.appliedCharacterStyle = "Superscrito_titulo_unidade_2_CV";

                      app.activeDocument.changeGrep();

                     

                      app.findGrepPreferences = NothingEnum.nothing;

                      app.changeGrepPreferences = NothingEnum.nothing;

               

              Good luck, hug!

              • 4. Re: Paste with formatting from word file
                tpk1982 Level 4

                Hi Leo,

                 

                Thanks for your response.

                 

                One thing i have to say, if you copy one paragraph with italic and paste into indesign document, it will lost its italic style. I did the paragraph style override. See the tried coding, it is working fine

                 

                app.menuActions.item("$ID/Paste").invoke();
                var myDoc=app.activeDocument;  
                var mySel=app.selection[0];
                var mypara=mySel.paragraphs[0].insertionPoints[0].paragraphs[0].appliedParagraphStyle.name;
                app.findTextPreferences = null;     app.changeTextPreferences = null;  
                app.findTextPreferences.fontStyle="Bold";
                app.findTextPreferences.appliedParagraphStyle = mypara.toString();
                app.changeTextPreferences.appliedCharacterStyle=myDoc.characterStyleGroups.itemByName("General").characterStyles.item("Bold");
                app.changeTextPreferences.appliedParagraphStyle =mypara.toString();  
                app.changeText();
                

                 

                Now my problem is this paragraph style is in style group. I have to get from the different style group and reapply.

                 

                The above coding will work perfectly if the paragraph style is not in style group

                 

                Regards,

                Karthi

                • 5. Re: Paste with formatting from word file
                  tpk1982 Level 4

                  Hi,

                   

                  How to get paragraph style name from group? Or is it possible to invoke the Clear Overrides from menu action?

                   

                  Screen Shot 2016-02-12 at 6.25.57 PM.png

                  • 6. Re: Paste with formatting from word file
                    Laubender Adobe Community Professional & MVP

                    Hi Karthi,

                    did you see the following script by Marc Autret?

                     

                    RichPaste 1.6

                    RichPaste | Copy and Paste with Minimal Formatting [UPDATE]

                    Marc Autret | January 12, 2016

                     

                    Indiscripts :: RichPaste | Copy and Paste with Minimal Formatting [UPDATE]

                     

                    Uwe

                    • 7. Re: Paste with formatting from word file
                      tpk1982 Level 4

                      Hi Uwe,

                       

                      Yes i saw the Marc script as well as Jongware's Preptext script. This scripts are not fulfilling my requirement.

                       

                      But i need only one thing to finish my script. How to get paragraph style name from group? Or is it possible to invoke the Clear Overrides from menu action?

                       

                      Regards,

                      Karthi