Skip to main content
Participating Frequently
January 30, 2017
Answered

Is it possible to remove all the empty artboards using script?

  • January 30, 2017
  • 3 replies
  • 5082 views

The Question is I have nearly about 20 artboards where by chance the number of artboards used may differ based on file.

So I need to remove all the empty artboards.

This topic has been closed for replies.
Correct answer Charu Rajput

Hi,

Due to some issues of moving code to new forums, code get corrupted. Here is the corrcet version of the above code

#target illustrator

function test() {
    var doc = app.activeDocument, thisBoard, selectedObjects;
    doc.selection = null;
    for (var i = doc.artboards.length - 1; i >= 0; i--) {
        thisBoard = doc.artboards[i];
        if (doc.artboards.length > 1) {
            doc.artboards.setActiveArtboardIndex(i);
            selectedObjects = doc.selectObjectsOnActiveArtboard();
            if (doc.selection.length < 1 || doc.selection == null) {
                thisBoard.remove();
            }
        }
    }
};

test();

 

3 replies

DiamondLeopard
Participant
April 26, 2020

Hi there,

 

I have been able to run the script inside adobe illustrator but I keep getting this error ->

 

Error 1242: Illegal argument - argument 1
- Required value is missing
Linke:21
-> thisBoard.remove();

 

I appreciate this script was originally posted 3 years ago and illustrator has changed in that time, I wonder if anyone could help me with a new solution?

 

Just looking for an action or script to remove/delete artboards with no artwork on them (Empty Artboards) 

 

Kind Regards

renaemp2
Inspiring
June 8, 2021

Another year later… was this ever resolved? I am getting this same error and I have no idea how to fix it (yes, I have ExtendScript Toolkit).

 

Any help is appreciated!

Thanks

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
June 8, 2021

Hi,

Due to some issues of moving code to new forums, code get corrupted. Here is the corrcet version of the above code

#target illustrator

function test() {
    var doc = app.activeDocument, thisBoard, selectedObjects;
    doc.selection = null;
    for (var i = doc.artboards.length - 1; i >= 0; i--) {
        thisBoard = doc.artboards[i];
        if (doc.artboards.length > 1) {
            doc.artboards.setActiveArtboardIndex(i);
            selectedObjects = doc.selectObjectsOnActiveArtboard();
            if (doc.selection.length < 1 || doc.selection == null) {
                thisBoard.remove();
            }
        }
    }
};

test();

 

Best regards
Participating Frequently
January 30, 2017

Thanks it works. You helped me and my team.

Silly-V
Legend
January 30, 2017

Hello!  The answer is yes, it's possible! The below snippet may be what you need.

#target illustrator

function test(){

     var doc = app.activeDocument, thisBoard, selectedObjects;

     doc.selection = null;

     for (var i = doc.artboards.length - 1; i >= 0; i--) {

          thisBoard = doc.artboards;

          if(doc.artboards.length > 1){

               doc.artboards.setActiveArtboardIndex(i);

               selectedObjects = doc.selectObjectsOnActiveArtboard();

               if(doc.selection.length < 1 || doc.selection == null){

                    thisBoard.remove();

               }

          }

     }

};

test();