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

Unable to add [Basic Paragraph] when generating TOC

Community Beginner ,
Mar 27, 2020 Mar 27, 2020

Copy link to clipboard

Copied

Hi,

 

When generating a TOC, one of the styles I want to be able to add is the [Basic Paragraph] style in case no custom style has been used. I can add it when generating a TOC manually but it errors when I try to add this style in extendscript. Has anyone managed to acheive this? The relevant code is below:

 

myTOC.tocStyleEntries.add ({
formatStyle:"[Basic Paragraph]",
name:"[Basic Paragraph]",
level:1,
separator:"\t",
pageNumberPosition: PageNumberPosition.BEFORE_ENTRY,
});

TOPICS
Scripting

Views

271

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 , Mar 30, 2020 Mar 30, 2020

Hi Stuart,

after more testing I found a way to apply the Basic Paragraph Style by name as value to tocStyleEntry.name.

You have to use the "international" string for this style. And that is:

 

 

"$ID/NormalParagraphStyle"

 

 

How did I find this one?

I ran app.findKeyStrings() on the name of paragraphStyles[0] paragraphStyles[1]:

 

 

// Returns an array:
app.findKeyStrings( app.documents[0].paragraphStyles[1].name );

 

 

Important Note 1:

app.findKeyStrings() always returns an array.

Length coul

...

Votes

Translate

Translate
Community Expert ,
Mar 27, 2020 Mar 27, 2020

Copy link to clipboard

Copied

Hi Stuart.

the basic paragraph style can be reached by its index as well.

You are trying this by its name.

 

This would assign a paragraph style object with index 1, that's always the basic paragraph style, and not a name:

formatStyle: app.documents[0].paragraphStyles[1] ,

 

I did not test this, but I hope it helps…

 

Regards,
Uwe Laubender

( ACP )

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 ,
Mar 29, 2020 Mar 29, 2020

Copy link to clipboard

Copied

Hi Uwe,

Thank you for this. It works for the 'formatStyle' property but not for the 'name' property which seems to accept names only. I'm also wondering if overset text can be included in a script generated TOC as I can't find any reference to this.

Any help is much appreciated.

 

Regards

Stuart

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 ,
Mar 29, 2020 Mar 29, 2020

Copy link to clipboard

Copied

The name property?
That's only the name of the TOC style itself.

I think, you can name it like you want.

 

Sorry. After reading your code again, I see, that you talk about the name of a tocStyle entry.

 

Regards,
Uwe Laubender

( ACP )

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 ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Hi Stuart,

after more testing I found a way to apply the Basic Paragraph Style by name as value to tocStyleEntry.name.

You have to use the "international" string for this style. And that is:

 

 

"$ID/NormalParagraphStyle"

 

 

How did I find this one?

I ran app.findKeyStrings() on the name of paragraphStyles[0] paragraphStyles[1]:

 

 

// Returns an array:
app.findKeyStrings( app.documents[0].paragraphStyles[1].name );

 

 

Important Note 1:

app.findKeyStrings() always returns an array.

Length could be 0 when nothing is found or greater than one if one or more strings are found.

 

Important Note 2:

If you want to apply a paragraph style that is nested into a paragraph style group you have to use the following syntax for the string you apply to property name of the toc style entry:

 

 

"paragraph style group name:paragraph style name"

 

 

 

If the paragraph style is more than one group deep simply follow this rule:

 

 

"group-level-1 name:group-level-2 name:style name"

 

 

 

Regards,
Uwe Laubender

( ACP )

 

//EDITED

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 ,
Apr 16, 2020 Apr 16, 2020

Copy link to clipboard

Copied

LATEST

Hi Uwe,

Apologies for the delay in responding. Thank you so much for taking the trouble to find this out, it has helped enormously.

 

Regards

Stuart

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