Skip to main content
March 8, 2010
Question

Help with Notes Script

  • March 8, 2010
  • 3 replies
  • 630 views

Hello,

I have a notes script that looks for all notes in a document and outputs them all to a text file. It will look for notes in inline text frames, anchored objects, and regular text frames. However, it can't find notes that are in tables or overset text. Could anyone give me a hand? I have attached the script for your review.

Thanks,

Rob

This topic has been closed for replies.

3 replies

Harbs.
Legend
March 8, 2010

If you want overset notes, you need to work by the story, rather than

by the page.

You can get the notes in tables by using

myThingamagig.tables.everyItem().cells.everyItem().notes

Harbs

March 8, 2010

Thank you Harbs!

Peter Kahrel
Community Expert
Community Expert
March 8, 2010

If you know who wrote that script, ask them.

Peter

March 8, 2010

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/* Notes Script

*/

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function myExportNotes(myFolder)

{

    for (i=app.activeDocument.groups.length-1;i>=0;i--)

        app.activeDocument.groups.ungroup();

    for (i=app.activeDocument.textFrames.length-1;i>=0;i--)

    {

        if (app.activeDocument.textFrames.item(i).locked=='true')

            app.activeDocument.textFrames.item(i).locked='false';

    }

    var DName=myDocument.name.replace(".indd","");

    var myFilePath = myFolder + "/" +DName+"_Notes "+".txt";

    var myFile = new File(myFilePath);

    myFile.open("w");

    myFile.write("#\tPage\tUsername\tCreated Date\tModified Date\tNotes\n");

    //Collect Info About Notes

    var mypages=myDocument.pages.length;

    for(p=0;p<mypages;++p)

    {

        for (t=0;t<myDocument.pages.item(p).allPageItems.length;++t)

        {

            if(myDocument.pages.item(p).allPageItems.constructor.name=="TextFrame")

            {

                for (i=0;i<myDocument.pages.item(p).allPageItems.paragraphs.length;++i)

                {

                    for (j=0;j<myDocument.pages.item(p).allPageItems.paragraphs.item(i).notes.length;++j)

                    {

                        count=1;

                        if(x<=notecount)

                        {

                            x=x+1;

                            myFile.write(x+"\t");

                            try

                            {

                                myFile.write(String(myDocument.pages.item(p).name)+"\t");

                            }

                            catch(myError)

                            {

                                alert("Page Number not found for Note "+ x);

                                myFile.write("NIL"+"\t");

                            }

                            myFile.write(String(myDocument.pages.item(p).allPageItems.paragraphs.item(i).notes.item(j).userName)+"\t");

                            var str1=String(myDocument.pages.item(p).allPageItems.paragraphs.item(i).notes.item(j).creationDate);

                            var str2=str1.replace("GMT-0400","");

                            str2=str2.replace("GMT-0500","");

                            str2=str2.replace("GMT+0530","");

                            myFile.write(str2+"\t");

                            var str1=String(myDocument.pages.item(p).allPageItems.paragraphs.item(i).notes.item(j).modificationDate);

                            var str2=str1.replace("GMT-0400","");

                            str2=str2.replace("GMT-0500","");

                            str2=str2.replace("GMT+0530","");

                            myFile.write(str2+"\t");

                            myFile.write(myDocument.pages.item(p).allPageItems.paragraphs.item(i).notes.item(j).texts.item(0).contents+"\n");

                        }

                    }

                }

            }

        }

    }

    myFile.execute();

}//function ends

if(app.documents.length!= 0)

{

    var myDocument=app.activeDocument;

    var notecount=0;

    var x=0;

    var myStories=myDocument.stories.length;

    for(s=0;s<myStories;++s)

        notecount=myDocument.stories.item(s).notes.length+notecount;

    if(notecount==0)

    {

        alert("There are no Notes in the Document", "Notes");

        exit();

    }

    var myFolder = Folder.selectDialog ("The Report will be stored in the below selected folder", "The Report will be stored in the below selected folder");

    if(myFolder != null)

    {

   

    myExportNotes(myFolder);

    alert("Script Executed Successfully !!!", "Notes");

    }

}

else

{

alert("Please open a document and try again.", "Notes");

}