• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Automate a repetitive task when importing word document into indesign

Community Beginner ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Guys, good afternoon, how are you? I'm working on a complex exercise book with several modules and questions that teachers send in Word


Question example:

In this apparatus, the separation of substances occurs as a function of
a) of the different densities.
b) the different radii of rotation.
c) the different angular velocities.
d) the different amounts of each substance.
e) the different molecular cohesion of each substance.

Let's say there are 100 questions that have alternatives and these a) b) c) d) e)
I need it to have a different paragraph style.

Today I have to select each one of the alternatives and click on a paragraph that I created, my question is if there is a faster way, thanks!

Example of how it comes in Word:

Example of how it comes in Word.png

 

 

Example as I need - InDesign

Example as I need - InDesign.png

TOPICS
Feature request , How to , Scripting

Views

295

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 29, 2022 Jun 29, 2022

Hi @CleberRafael,

Here's a quick script to do what you want. It will search the whole document for paragraphs that begin with a letter with ). Let me know if it works for you. See attached document for example paragraph style with numbering.

- Mark

 

 

/**
 * Find answer paragraphs and apply paragraph style.
 * For Adobe Indesign 2022
 * 
 * by m1b
 * here: https://community.adobe.com/t5/indesign-discussions/automate-a-repetitive-task-when-importing-word-document-into-indesign/m-p/13038974#M4825
...

Votes

Translate

Translate
Community Expert ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

It sounds as if no styles were used in Word. Not unusual; even experienced Word users are style-averse. 🙂

 

There isn't any simple solution except to apply styles to each paragraph, whether it's done in Word and then imported, or done after import in InDesign. You will need two styles, one for the question and one for each answer selection. You could use a list style with auto-numbering to simplify the answer listing and numbering.

 

If you really want to do this in a few clicks, scripting can be used to automate the process. But someone would have to write the script for you (I am guessing it's not something you're familiar with). There are some adept script wizards here, though.

 

—


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.0 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Thank you very much for the answer, here's how I'm doing it: if I do it with numerical list it would duplicate and do a. a).... correct?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Yes, it will duplicate the hard-typed numbering, but you can use a few find-and-change operations to remove those. Using a list style will keep any answer list from being misnumbered (through a typing or editing mistake), and you can use some sophisticated paragraph spacing tricks (above, below and between) to get a clean layout without multiple styles or a lot of fiddling around.

 

—


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.0 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Hi @CleberRafael,

Here's a quick script to do what you want. It will search the whole document for paragraphs that begin with a letter with ). Let me know if it works for you. See attached document for example paragraph style with numbering.

- Mark

 

 

/**
 * Find answer paragraphs and apply paragraph style.
 * For Adobe Indesign 2022
 * 
 * by m1b
 * here: https://community.adobe.com/t5/indesign-discussions/automate-a-repetitive-task-when-importing-word-document-into-indesign/m-p/13038974#M482557
 * 
 * Assumes that paragraph style has
 * correct numbering set up, so it
 * removes the text.
 */

function main() {

    var doc = app.activeDocument,

        // the regex to find answer paragraphs
        // paragraphs that start with a) b) c) etc.
        myFindWhat = '^\\s*[a-z]\s?\\)\\s+',

        // change the found text to this
        myChangeTo = '\t',

        // put your paragraph style name here
        changeToStyleName = "Respostas",

        // get the paragraph style
        changeToStyle = doc.paragraphStyles.itemByName(changeToStyleName);

    if (!changeToStyle.isValid) {
        alert('There is no paragraph style named "' + changeToStyleName + '".');
        return;
    }

    // reset grep prefs
    app.findGrepPreferences = NothingEnum.NOTHING;
    app.changeGrepPreferences = NothingEnum.NOTHING;
    app.findGrepPreferences.findWhat = myFindWhat;
    // comment out the next line if you don't want to change the found text
    app.changeGrepPreferences.changeTo = String(myChangeTo);
    app.changeGrepPreferences.appliedParagraphStyle = changeToStyle;
    // do the change
    doc.stories.everyItem().paragraphs.everyItem().changeGrep();

}

app.doScript(
    main,
    ScriptLanguage.JAVASCRIPT,
    undefined,
    UndoModes.ENTIRE_SCRIPT,
    "Format Answers"
);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Man you are never AWESOME thank you so much, I thought it would be possible hahaha

One last question when I apply the script in my document it is sequential example:

 

a)
b)
c)
d)
e)
f)
g)

How do I automatically reset in e)?

Here's a video of a way I found on how to reset the numeric listing:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Oh! Yes, that's a matter of adjusting the paragraph styles. You will have a style for your questions, and a style for your answers. Set the numbering of the questions style to level 1, start at 1, with no text (don't show number) and then set the numbering of the answers style to level 2 of same list, continuing from last, with the a), b), c) numbering text. See my attached indesign file.

- Mark

 

Screen Shot 2022-06-30 at 10.50.27 am.pngScreen Shot 2022-06-30 at 10.50.40 am.pngScreen Shot 2022-06-30 at 10.50.51 am.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Now I got it friend, thank you very much!!! The document is almost perfect. There are 2 questions that happen: when I import from Word to indesign with the selected paragraph profile there are some questions that it keeps the Word font do you know why it happens? another question is when I run the script it changes from: 4mgª to 4mga, for some reason it loses formatting

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied


@CleberRafael wrote:

...it keeps the Word font do you know why it happens?


That is the default behaviour. When importing the Word doc, click the show options button and change to unformatted text there.

Screen Shot 2022-06-30 at 12.29.08 pm.png


@CleberRafael wrote:

when I run the script it changes from: 4mgª to 4mga, for some reason it loses formatting


This happens when applying the paragraph style and I'm not sure there is much you can do about this. A possible solution is to add a grep style to the paragraph style like this:

Screen Shot 2022-06-30 at 12.46.01 pm.png

Hope that helps. See attached sample doc.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

LATEST

Good morning friend, thank you very much for replying again, I tested the options that you told me more for some reason this happened:

Font Error.png

 

Even using the clean import option and with my paragraph option selected it for some reason leaves some in calibri, clicking again on the paragraph makes it right, but using this option wasn't it supposed to leave everything in the font I selected?

Importar opções.png

 

I tried using Grep but the same error happens, when I manually click on the answers paragraph it keeps the format:

Formatação Respostas.png

when I run your automatic script:

Executando Script.png

 

maybe I'm doing something basic wrong, I'll send you the files I'm using too:

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines