Skip to main content
Inspiring
May 23, 2025
Answered

exportFile() broken when upgrading to Illustrator 2025

  • May 23, 2025
  • 1 reply
  • 561 views

I have a script I've been using for over a decade that just broke when I upgraded to Illustrator 2025.  I'm exporting the artboards to Photoshop files using exportFile() and this now throws an "Error 1200: Internal Error".  I rely this script nearly every day at work, so I had to roll illustrator back.  This is a very generic error, so no idea if this issue can be fixed.

Correct answer m1b

Hi @urbanstarship I've can reproduce the issue on my system here. Not sure if it is a bug, per se, but it is certainly not helpful behaviour.

 

In this case I would be inclined—rather than lodge a bug report—to put in a check in your code for an empty artboard before exporting. Here is a script that exports every artboard in the document, but only after checking if it's empty or not. The check is a bit of a hack, and destroys the current selection.

- Mark

 

/**
 * @file Export Every Artboard As PSD.js
 * 
 * Example of checking whether an artboard
 * is empty before exporting.
 * 
 * @author m1b
 * @version 2025-05-28
 * @discussion https://community.adobe.com/t5/illustrator-discussions/exportfile-broken-when-upgrading-to-illustrator-2025/m-p/15344164
 */
(function () {

    var doc = app.activeDocument;

    if (!doc.fullName.exists)
        return alert('Please save this document first.');

    for (var i = 0; i < doc.artboards.length; i++)
        exportArtboardAsPSD(doc, i);

})();

function exportArtboardAsPSD(doc, index) {

    if (index < 0 || index > doc.artboards.length)
        throw new Error('exportArtboardAsPSD: bad `index` supplied.');

    // check if there's artwork on this artboard
    doc.selection = [];
    doc.artboards.setActiveArtboardIndex(index);
    app.executeMenuCommand('selectallinartboard');

    if (0 === doc.selection.length)
        // nothing on this artboard
        return;
    else
        doc.selection = [];

    var exportOptions = new ExportOptionsPhotoshop();

    // export artboard 1
    doc.artboards.setActiveArtboardIndex(index);
    exportOptions.artboardRange = index+1;

    exportOptions.antiAliasing = true;
    exportOptions.artBoardClipping = true;
    exportOptions.editableText = true;
    exportOptions.imageColorSpace = ImageColorSpace.CMYK;
    exportOptions.maximumEditability = true;
    exportOptions.resolution = 72;
    exportOptions.saveMultipleArtboards = true;
    exportOptions.warnings = false;
    exportOptions.writeLayers = true;

    var file = File(doc.fullName.parent + '/test_' + doc.artboards[index].name + '.psd');

    doc.exportFile(file, ExportType.PHOTOSHOP, exportOptions);

    // reveal the exported file
    // file.parent.execute();

};

 

1 reply

m1b
Community Expert
Community Expert
May 25, 2025

Hi @urbanstarship I wrote a quick test case and it worked fine on AI 29.5.1 (MacOS 15.5). Can you try it and see what happens?

- Mark

 

/**
 * @file Test Case For ExportFile As PSD.js
 * 
 * Saves active document's artboard 1 as "test"
 * into the same folder as the active document.
 * 
 * @author m1b
 * @version 2025-05-25
 */
(function () {

    var doc = app.activeDocument;

    if (!doc.fullName.exists)
        return alert('Please save this document first.');

    var exportOptions = new ExportOptionsPhotoshop();

    // export artboard 1
    doc.artboards.setActiveArtboardIndex(0);
    exportOptions.artboardRange = 1;

    exportOptions.antiAliasing = true;
    exportOptions.artBoardClipping = true;
    exportOptions.editableText = true;
    exportOptions.imageColorSpace = ImageColorSpace.CMYK;
    exportOptions.maximumEditability = true;
    exportOptions.resolution = 72;
    exportOptions.saveMultipleArtboards = true;
    exportOptions.warnings = false;
    exportOptions.writeLayers = true;

    var file = File(doc.fullName.parent + '/test.psd');

    doc.exportFile(file, ExportType.PHOTOSHOP, exportOptions);

    // reveal the exported file
    file.parent.execute();

})();

 

P.S. if this works for you, then the next step could be to try exporting to the same path that you are using in your real script. And then try adjusting the options so that this test case matches your real script, trying to narrow down thing that causes the failure in the latest Illustrator. Once we've locked it down, we can lodge a bug report.

 

Edit 2025-05-25: changed !doc.saved to !doc.fullName.exists as the test for a "saved" document.

Inspiring
May 28, 2025

@m1b Would be great to see if you can reproduce this on your end by trying this on file with multiple artboards, some of them empty.

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
May 28, 2025

Hi @urbanstarship I've can reproduce the issue on my system here. Not sure if it is a bug, per se, but it is certainly not helpful behaviour.

 

In this case I would be inclined—rather than lodge a bug report—to put in a check in your code for an empty artboard before exporting. Here is a script that exports every artboard in the document, but only after checking if it's empty or not. The check is a bit of a hack, and destroys the current selection.

- Mark

 

/**
 * @file Export Every Artboard As PSD.js
 * 
 * Example of checking whether an artboard
 * is empty before exporting.
 * 
 * @author m1b
 * @version 2025-05-28
 * @discussion https://community.adobe.com/t5/illustrator-discussions/exportfile-broken-when-upgrading-to-illustrator-2025/m-p/15344164
 */
(function () {

    var doc = app.activeDocument;

    if (!doc.fullName.exists)
        return alert('Please save this document first.');

    for (var i = 0; i < doc.artboards.length; i++)
        exportArtboardAsPSD(doc, i);

})();

function exportArtboardAsPSD(doc, index) {

    if (index < 0 || index > doc.artboards.length)
        throw new Error('exportArtboardAsPSD: bad `index` supplied.');

    // check if there's artwork on this artboard
    doc.selection = [];
    doc.artboards.setActiveArtboardIndex(index);
    app.executeMenuCommand('selectallinartboard');

    if (0 === doc.selection.length)
        // nothing on this artboard
        return;
    else
        doc.selection = [];

    var exportOptions = new ExportOptionsPhotoshop();

    // export artboard 1
    doc.artboards.setActiveArtboardIndex(index);
    exportOptions.artboardRange = index+1;

    exportOptions.antiAliasing = true;
    exportOptions.artBoardClipping = true;
    exportOptions.editableText = true;
    exportOptions.imageColorSpace = ImageColorSpace.CMYK;
    exportOptions.maximumEditability = true;
    exportOptions.resolution = 72;
    exportOptions.saveMultipleArtboards = true;
    exportOptions.warnings = false;
    exportOptions.writeLayers = true;

    var file = File(doc.fullName.parent + '/test_' + doc.artboards[index].name + '.psd');

    doc.exportFile(file, ExportType.PHOTOSHOP, exportOptions);

    // reveal the exported file
    // file.parent.execute();

};