Skip to main content
RockScript
Known Participant
June 29, 2009
Answered

To lock text Frame through CSV file input

  • June 29, 2009
  • 1 reply
  • 654 views

i want to lock the lock the textframe even wise. But i input will be getting from csv file. ex if i enter 3;9 that particular page textFrame only lock.

How to do. pls could anyone tell me.

This topic has been closed for replies.
Correct answer interesting_Flower157F

The following should do the trick:

if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    main();
} else {
    alert("Please open a document");
}
function main () {
    var myFile = File.openDialog("Choose the file containing the semicolon separeted page list");

    var myResult = myFile.open("r", undefined, undefined);
   
    if(myResult == true){
       
        var myFileContent = myFile.read();
        var myPageLockArray = myFileContent.split(";");
        alert(myPageLockArray);
       
        for (i = 0; i < myPageLockArray.length; i++) {
            var myPageNum = myPageLockArray - 1;
            try {
                var myPage = myDocument.pages[myPageNum];
                var myTextFrame = myPage.textFrames[0]; // Assuming there is only one textframe on the page
                myTextFrame.locked = true;
            } catch (e) {
                alert(e);
            }
        }
        myFile.close();
    }
}

--

Thomas B. Nielsen

http://www.nobrainer.dk

1 reply

interesting_Flower157F
Inspiring
June 29, 2009

The following should do the trick:

if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    main();
} else {
    alert("Please open a document");
}
function main () {
    var myFile = File.openDialog("Choose the file containing the semicolon separeted page list");

    var myResult = myFile.open("r", undefined, undefined);
   
    if(myResult == true){
       
        var myFileContent = myFile.read();
        var myPageLockArray = myFileContent.split(";");
        alert(myPageLockArray);
       
        for (i = 0; i < myPageLockArray.length; i++) {
            var myPageNum = myPageLockArray - 1;
            try {
                var myPage = myDocument.pages[myPageNum];
                var myTextFrame = myPage.textFrames[0]; // Assuming there is only one textframe on the page
                myTextFrame.locked = true;
            } catch (e) {
                alert(e);
            }
        }
        myFile.close();
    }
}

--

Thomas B. Nielsen

http://www.nobrainer.dk

RockScript
Known Participant
June 29, 2009

Thank you nielse. it's very helpful to me.

Thank u once again