Skip to main content
Participating Frequently
September 28, 2018
Question

How to get FileName path from dialogBox?

  • September 28, 2018
  • 2 replies
  • 1810 views

Hi,

How to get FileName path from dialogBox?

I want one dialog box with two question.

First question is:  which file do you want work with? and open button

Second question: enter page range AND here some INPUT FIELD

So I want get string with file path and string with range

This topic has been closed for replies.

2 replies

OndrejLAuthor
Participating Frequently
October 10, 2018

I did it in two steps

// dialogBox just for information

app.alert({

cMsg: "select a file",

nIcon: 2

});

//open a window for select a file

// we'll never look at it so size is unimportant

var tmpDoc = app.newDoc(0,0);

// Create the Text Field

var fld = tmpDoc.addField("tmpTxt","text",0,[0,0,0,0]);

// Set up the Text field so the file dialog can be called

fld.fileSelect = true;

// Display File Open Dialog

fld.browseForFileToSubmit();

// save the selected file path to a local variable

// so it can be used later

var path_second_file = fld.value;

// Close Document without saving

tmpDoc.closeDoc(true);

console.println(path_second_file);

Legend
September 28, 2018

You probably won't be able to work with files opened from JavaScript, unless they set disclosed. Best to have the user open it, then run your script.

OndrejLAuthor
Participating Frequently
September 28, 2018

No i just want have full path to file

try67
Community Expert
Community Expert
September 28, 2018

You can use the app.browseForDoc() method to prompt the user to select a file. It then returns that file's path, inside of an object.