Skip to main content
tpk1982
Legend
February 12, 2016
Question

Paste with formatting from word file

  • February 12, 2016
  • 1 reply
  • 976 views

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

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

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

This topic has been closed for replies.

1 reply

LeoMari-eL6mBl
Inspiring
February 12, 2016

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.

tpk1982
tpk1982Author
Legend
February 12, 2016

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

LeoMari-eL6mBl
Inspiring
February 12, 2016

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!