Skip to main content
dublove
Legend
Oct 30, 2026 3:39 AM UTC
Answered

Is it possible to open the 'Open dialog box' with the default path and select a file by default using a script?

For example, I want to open the "D: \ AA \" path by default and select A1. indd by default

var defPath ="D:\AA\";
var myFile = File.openDialog("Select File");
if (myFile) {
app.open(myFile);
} else {
alert("No file selected");
}

 

    Manan JoshiCorrect answer
    Community Expert
    Oct 30, 2026 4:15 AM UTC

    I don’t think you can select the file but you can select till the folder. This is based on my testing on Mac. try the following

    var defaultFile = File("Path of your indd");
    var myFile = defaultFile.openDlg("Select File", "*.indd", false);

    if (myFile) {
    app.open(myFile);
    } else {
    alert("No file selected");
    }

     

    -Manan

    6 replies

    Manan JoshiCommunity ExpertCorrect answer
    Community Expert
    Oct 30, 2026 4:15 AM UTC

    I don’t think you can select the file but you can select till the folder. This is based on my testing on Mac. try the following

    var defaultFile = File("Path of your indd");
    var myFile = defaultFile.openDlg("Select File", "*.indd", false);

    if (myFile) {
    app.open(myFile);
    } else {
    alert("No file selected");
    }

     

    Translate
    -Manan
    dublove
    dubloveAuthor
    Legend
    Oct 30, 2026 4:45 AM UTC

    Hi Manan Joshi

    Thank you, it was successful.

    Translate
    Community Expert
    Oct 30, 2026 4:47 AM UTC

    Happy to help

    Translate
    -Manan