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

undo() - uncaught exception (-29) error

New Here ,
Oct 13, 2025 Oct 13, 2025

Hello Experts,

 

I'm using the InDesign 20.4.1.

 

Steps to reproduce the issues:

1. Create a master page containing the multiple text frames.
2. Apply the master page to the interior pages (ensure there are at least 5–10 pages).
3. Save the document, close it, and reopen it to clear the history stack.

 

Here is my script to undo the overridden textframe by the script:

 

var Doc = app.activeDocument;
for (z = 0; z < Doc.pages.length; z++) {
page = Doc.pages[z];
var count = 0;
for (j = 0, k = page.appliedMaster.textFrames.length / 2 + 1; j <= k; j++) {
if (page.appliedMaster.textFrames[j].constructor.name == "TextFrame") {
try { page.appliedMaster.textFrames[j].override(page); count++; } catch (e) { continue; }
try { Doc.undo(); } catch (e) { alert(e);}
}

}
}


If there is no undoable data, the process must be routed to catch statement and alert the error message (e).

While running the above script, the attached uncaught exception error occurred.

 

Note: I couldn't reproduce the same issue in InDesign 19.5.

 

Thanks in advance.

 

Regards,
Ashrafali R.

TOPICS
Bug , Scripting
177
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

correct answers 1 Correct answer

Guide , Oct 14, 2025 Oct 14, 2025

Hi Ashrafali R.

 

Not sure what you're trying to achieve but playing with doc.undo() is not a good idea unless you have no other option.

 

In your particular case, it seems that you need to detect, count and/or report text frames according to their ‘overridden’ state relative to the parent (=master) page. Properties like page.masterPageItems, item.overridden and possibly item.overriddenMasterPageItem should be sufficient to safely investigate.

 

Here is a messy and oversimplified example that illustra

...
Translate
New Here ,
Oct 14, 2025 Oct 14, 2025

Hi,

 

Thanks for your response.

 

I do try the suggested way. It override the master textframes but it does not undo its overrides. i.e. It enables all the master textframes.

 

Regards,

Ashrafali R.

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 ,
Oct 14, 2025 Oct 14, 2025
quote

Thanks for your response.


By @ashrafali_r_srm

 

that response was posted by an AI spambot. you can ignore it. the user will be eradicated soon, hopefully.

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
Guide ,
Oct 14, 2025 Oct 14, 2025
LATEST

Hi Ashrafali R.

 

Not sure what you're trying to achieve but playing with doc.undo() is not a good idea unless you have no other option.

 

In your particular case, it seems that you need to detect, count and/or report text frames according to their ‘overridden’ state relative to the parent (=master) page. Properties like page.masterPageItems, item.overridden and possibly item.overriddenMasterPageItem should be sufficient to safely investigate.

 

Here is a messy and oversimplified example that illustrates the use of these features:

 

(function(  doc,pgs,pg,mfs,tfs,i,n,t,s)
//----------------------------------
// Demo: Simple Text Frame Report
// - assuming at most ONE parent page in the hierarchy
// - disregarding grouped/nested frames etc.
{
   doc = app.properties.activeDocument;
   if( !doc ) return;
   
   pgs = doc.pages.everyItem().getElements();
   for( ; pg=pgs.pop() ; )
   {
      // Master frames (not overridden).
      mfs = pg.masterPageItems || [];
      for
      (
         i=mfs.length ; i-- ;
         'TextFrame' != mfs[i].constructor.name
         && mfs.splice(i,1)
      );

      // Local frames (incl. overridden)
      tfs = [];
      n = (t=pg.textFrames).length;
      while( n )
      {
         t = t.everyItem();
         s = t.overridden.join('')
            .replace(/true/g,'1')
            .replace(/false/g,'0');

         if( -1 == s.indexOf('1') ) break;

         for
         (
            tfs=t.getElements(), i=n ;
            i-- ;
            '1' != s.charAt(i) && tfs.splice(i,1)
         );

         break;
      }
      
      // Summary
      s = "Page " + pg.name + "\r" +
         "Overall visible frames: " + (n+mfs.length) + "\r" +
         "----------------------\r\r" +
         "On Master: " + mfs.length + "\r\r" +
         "On Page:   " + n + "\r" +
         " - from master: " + tfs.length + "\r" +
         " - others:      " + (n-tfs.length);
      alert( s );
      
      // At this point,
      // the array `mfs` contains the master (not overridden) frames,
      // the array `tfs` contains the local frames that were overridden.
   }

})();

 

Best,

M

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