Skip to main content
Participant
January 22, 2026

'TextDocument' code not working in AE 26

  • January 22, 2026
  • 4 replies
  • 56 views

Hi, 

I've got a *.mogrt template which was using the following block of code:

// --- Source: DOG MASTER ---
var M       = comp("DOG MASTER");
var srcDoc  = M.layer(13).text.sourceText;               // TextDocument (safe)
var size    = M.layer(1).effect("Size")("Slider");       // numeric
// Prefer string if available; otherwise pass the TextDocument directly.
var srcText = (srcDoc && srcDoc.text !== undefined) ? srcDoc.text : srcDoc;
// --- Apply on THIS layer using the modern style API ---
try {
  var st = text.sourceText.style;
  // Make sure it will render (some styles can have fill disabled)
  st.applyFill = true;
  // Set true font size and then apply content
  st.setFontSize(size).setText(srcText);
} catch (err) {
  // Fallback for older AE / legacy engine: build a TextDocument manually
  var td = new TextDocument( (srcDoc && srcDoc.text !== undefined) ? srcDoc.text : (""+srcDoc) );
  // carry over some sane defaults from current value
  var cur = value;
  td.font          = cur.font;
  td.applyFill     = true;
  td.fillColor     = cur.fillColor;
  td.justification = cur.justification;
  td.tracking      = cur.tracking;
  td.leading       = cur.leading;
  td.autoLeading   = cur.autoLeading;
  td.fontSize      = size;
  td;
}

 

It's a little bit unwieldy, but it worked... until version 26 which has now completley broken it.

I'm getting the following error on line 6
"Error: text and textAttime() can only be used with dropdown menu properties"

Does anyone have any idea why this could be happening, and why it previously worked?

4 replies

JHenry1Author
Participant
January 22, 2026

Thanks @JohnColombo17100380 that's incredibly helpful and sorts my issue.

Strange that the other issue wasn't replicating the same results for you, however I can just revert to my original code block with your amended code now instead.

Happy to share a project over email if it helps, but can't post it publically due to commercially sensitive nature of the file :). 

JohnColombo17100380
Community Manager
Community Manager
January 22, 2026

To the other issue you posted, that expression is working for me in 26.0 when I set up the project with a "DOG MASTER" comp and a Size slider inside it, so that seems unrelated to the original issue you posted above. Happy to dig more into that one if you can share a project with your setup.

 

Cheers,

- John, After Effects Engineering Team 

JohnColombo17100380
Community Manager
Community Manager
January 22, 2026

Hi @JHenry1,
Thank you for reporting this issue. This appears related to the addition of the ".text" attribute for Dropdown Menus in 26.0; we now have a bug filed to investigate avoiding this issue in a future version of AE.

To fix the issue in the expression, try changing the first "srcDoc.text !== undefined" on line 6 to "srcDoc.matchName === "ADE Text Document"  e.g. instead of:

var srcText = (srcDoc && srcDoc.text !== undefined) ? srcDoc.text : srcDoc;

This should allow the expression to behave the same way it did previously:

var srcText = (srcDoc && srcDoc.matchName === "ADBE Text Document") ? srcDoc.text : srcDoc;



Looking at the comments, though, the intent is to prefer the string from the Source Text property, so that would be more effectively pulled with:

var srcText = srcDoc.value.toString();

No need to check for the ".text" property, which also avoids the issue.

Thanks again for reporting this, and please let us know if that change works as you expect.

Cheers,

- John, After Effects Engineering Team 

JHenry1Author
Participant
January 22, 2026

I cant seem to edit my original post, and I keep getting authentication failed errors when I'm posting this, but just to follow up.

This code is applied to a 'Source Text' property on a layer, which then looks at my master comp and gets a value from layer 13 (a text layer, dynamically driven via a text box in my essential graphics panel). Up until version 26, it displayed the value from layer 13 and let me use a slider (from layer 1 of the master comp) to change the font size within set parameters.

In version 26 this is not working.

I've tried simplifying the code block to:

var M = comp("DOG MASTER");
var Text = thisComp.layer("Values").text.sourceText;
var size = M.layer(1).effect("Size")("Slider");

Text.style.setFontSize(size);

This isnt woking though and is just showing the fall back text. If I remove: 

style.setFontSize(size)

it displays the correct value from the text layer, but as soon as I try and use setFontSize it defaults back to the fallback value (though the slider does work).

Is this a bug introduced in version 26?