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

Break links to style

Explorer ,
Apr 29, 2022 Apr 29, 2022

Is there a way to break links to style on multiple pages at a time? I have to move pages from other documents into a document and I don't want to bring the styles in with it. 

TOPICS
How to
1.8K
Translate
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
Advisor ,
Apr 29, 2022 Apr 29, 2022

If the text is threaded, of course, you can Select All and choose Break Links from the Para Styles menu. If the frames are not threaded, I think you'll have to select each frame. You can select multiple text frames and Break Links on all of them at once, provided they are not threaded to another page/spread. 

The only other thing I can think of is to search out whether there's a script to automate further.

Translate
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
LEGEND ,
Dec 12, 2023 Dec 12, 2023

It's about Char/Para Styles - not links between TextFrames.

 

Translate
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
Participant ,
Dec 12, 2023 Dec 12, 2023

I see that Diane understood well what it was about, and gave correct instructions to break the links of ALL paragraphs to their respective styles in one or in multiple threaded text frames. Inasmuch, she exactly answered the question.

Translate
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 ,
Dec 12, 2023 Dec 12, 2023

The script I posted will break the paragraph style link to all of the document’s text frame’s paragraphs. It will not get text in tables, but that could be added.

Translate
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 ,
Dec 12, 2023 Dec 12, 2023

This should also break paragraph style links in table cells:

 

var d = app.activeDocument
var bls =  app.menuActions.itemByID(8500);
var p = d.stories.everyItem().paragraphs.everyItem().getElements();

for (var i = 0; i < p.length; i++){
    p[i].select()
    if(bls.enabled){  
        bls.invoke();  
    }; 
}; 

var c = d.stories.everyItem().tables.everyItem().cells.everyItem().paragraphs.everyItem().getElements();
for (var i = 0; i < c.length; i++){
    c[i].select()
    if(bls.enabled){  
        bls.invoke();  
    }; 
}; 
Translate
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
LEGEND ,
Dec 12, 2023 Dec 12, 2023

But 8500 and 8501 can be executed on whole Stories AND whole Tables... 

 

No need to iterate through paragraphs - in the Stories nor in the Cells. 

 

Translate
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 ,
Dec 13, 2023 Dec 13, 2023

That’s a good idea, but I think you have to select the texts of the stories:

 

var d = app.activeDocument
var bls =  app.menuActions.itemByID(8500);
try {
    var t = d.stories.everyItem().texts.everyItem().getElements();
    for (var i = 0; i < t.length; i++){
        t[i].select()
        if(bls.enabled){  
            bls.invoke();  
        }; 
    }; 
    var c = d.stories.everyItem().tables.everyItem().cells.everyItem().texts.everyItem().getElements();
    for (var i = 0; i < c.length; i++){
        c[i].select()
        if(bls.enabled){  
            bls.invoke();  
        }; 
    }; 
}catch(e) {}

 

Translate
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
LEGEND ,
Dec 13, 2023 Dec 13, 2023

Yes, I know, you can't select Story - you have to select its Text. 

 

But for Tables - you can select a whole Table - so there is no need to process each Cell individually. 

 

Translate
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
Participant ,
Dec 13, 2023 Dec 13, 2023

If you'd like to do it really well, you'd need in fact to iterate through each cell, looking recursively at its content - since a cell can contain other tables or text frames containing tables and so on.
Moreover, it is explicitely not enough to select the table, hoping that cells are worked off automatically when invoking a table-related command.
Anyway - you'd really consider using the techniques explained below instead of invoking menu commands which should be the very last option to choose.
Just a simple thing: Have you tried invoking a menu command during this menu command has been taken out of the menus using "Edit > Menus"? Fingers crossed that it works.

Translate
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
LEGEND ,
Dec 13, 2023 Dec 13, 2023

All valid points...

 

But searching for "<0016>" will help to quickly find all Tables - instead of iterating through all Cells:

 

https://creativepro.com/use-findchange-to-find-tables/

 

RobertTkaczyk_0-1702476540752.png

 

Translate
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
LEGEND ,
Dec 13, 2023 Dec 13, 2023
LATEST

Of course the correct structure of the nested Tables should be like this:

 

RobertTkaczyk_0-1702513144072.png

 

Translate
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
LEGEND ,
Dec 13, 2023 Dec 13, 2023

This is my version:

 

RobertTkaczyk_1-1702475849919.png

 

Translate
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 ,
Apr 30, 2022 Apr 30, 2022

Hi @Veronica22551996i6fw , I don’t think there is a break link to style command in the scripting API, but you can select all the paragraphs and invoke the menu item via scripting, so you can try this:

 

 

var doc = app.activeDocument
var bls =  app.menuActions.itemByID(8500)

for(var i=0; i < doc.stories.length; i++){  
    var s = doc.stories.item(i);  
    for(var j=0; j < s.paragraphs.length; j++){  
        var p=s.paragraphs[j]; 
        p.select()
        if(bls.enabled){  
            bls.invoke();  
        }; 
    }  
} 

 

Translate
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 ,
Dec 07, 2023 Dec 07, 2023

You are the life saviour! I've been lookind for this for literally years.

Since just assigning a key combination to this option gives ugly results.

Translate
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
Participant ,
Dec 12, 2023 Dec 12, 2023

In fact there is unfortunately no command like "...breakLinkToStyle(...)" or so. What you need to do is the following in order to break the link from ... :
table to table style:

table.appliedTableStyle = app.activeDocument.tablesStyles[0];
table.clearTableStyleOverrides();

cell to cell style: analogous, replacing "table" by "cell";

object to object style: analogous, replacing "table" by "object";

paragraph from paragraph style:

text..applyParagraphStyle(app.activeDocument.paragraphStyles[0], false);

character from character style:  analoguous, replacing "Paragraph" by "Character".

Not kind of straighforward, but anyway, it works.

Translate
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
Participant ,
Dec 12, 2023 Dec 12, 2023

Sorry, obviously only one period character in

text.applyParagraphStyle(.....);

Translate
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