Skip to main content
Known Participant
August 22, 2017
Question

JS doesn't find file on network drive only on local drive

  • August 22, 2017
  • 2 replies
  • 3614 views

Dear all,

I have an issue with my script. It is a JS for InDesign (CS6) getting data from Excel and generating a InDesign file with links from it. It was working great for two month, no issues. Suddenly, my boss used the script on her computer (a copy of the file, so my file is still 'fine') and it stopped detecting the Excel file path on the network drive.

If I change the first letter to a local drive (and compy the whole folder path) it detects the file and everything runs smoothly?!

Why? The letter of the network drive is correct, I checked the path now 3 times letter by letter, sign by sign, retyped the path, restartet the computer, reconnected the network drive, I have no clue what happened overnight to the script.

This is the "file checking part":

function myFileChecking(){

               //Define the file I want to use

              ExcelPath = new File("D:/Folder1/Folder_2/Folder3/file.xlsx");

           //If NOT (!) the indicated Excel-file exist do the following

           if(!ExcelPath.exists) { 

                          alert("Excel Datei ist nicht im Ordner: Speichern Sie ExcelDatei unter file.xlsx im Folder ab.");

           //If the indicated Excel-file exist do the following stuff in the else{}

           else { // the following lines start the functions, one after the other

                    myDocSetup();

                    myMasterPage();

                    GetExcelData();

                    myExcelImport();

                    myTextFrameSetup();

                    myEnteringExcelData();

              } // closing of else

        } // closing of function myFileChecking

Same issue with saving the file and exporting it as interactive pdf:

//If the active document has not been saved (ever), save it.

if(app.activeDocument.saved == false){

//If you do not provide a file name, InDesign displays the Save dialog box.

app.activeDocument.save(File("Q:/Folder1/Folder_2/Folder3/InDesignFile.indd"));

}


😧 would be the loval drive, this works.

Q: would be the network drive, doesn't work.

Why?!?!?!?!

Any ideas?!

Best

Cleo

This topic has been closed for replies.

2 replies

Jump_Over
Legend
August 22, 2017

Hi,

File.openDialog() is a method to return a File (chosen in dialog).

It is not opening any file. You can choose any file, even xlsx.

Copying displayed path doesn't work?

Jarek

Cleo_helmAuthor
Known Participant
August 22, 2017

Hi Jarek,

ok I checked again, I think I didn't understand your last message correctly:

when doing:

var mFile = File.openDialog();

1) alert(mFile.fsName);

--> I get: /q/ZZZ_Sonstiges/HMGU_Struktur/HMGU_structure_incl_PSP_elements_XXX/Institute-NWG-KKG-Liste.xlsx

2) alert(mFile.fsName);

--> I get: Q:\ZZZ_Sonstiges\HMGU_Struktur\HMGU_structure_incl_PSP_elements_XXX\Institute-NWG-KKG-Liste.xlsx

3) alert(mFile.parent);

--> I get: /q/ZZZ_Sonstiges/HMGU_Struktur/HMGU_structure_incl_PSP_elements_XXX

Cleo_helmAuthor
Known Participant
August 23, 2017

Update: It is working again. Did I change anything. No.

Resaon: I have no clue, I had the feeling that it might be the network connection.

There seemed to be a computer issue for whatever reason today, crashing the whole network connection. After this was partly fixed I disconnected again the network drive (Q), which I could click on and saw the folders and could open files of this network drive, but windows told me there is not such a drive... Strange.

Finally, after reconnecting to the network drive, everything is working again.

Yeah!!!

So issue seems to be more the network drives than the script. But thanks for all your suggestions.

Best

Cleo

tpk1982
Legend
August 22, 2017

change the two path line as below.. Hope it will work then

ExcelPath = new File("/D/Folder1/Folder_2/Folder3/file.xlsx"); 

app.activeDocument.save(File("/Q/Folder1/Folder_2/Folder3/InDesignFile.indd")); 

Cleo_helmAuthor
Known Participant
August 22, 2017

No, neither does /Q:/ nor /Q/ work.

It worked two month long like this (using it once or twice a week). There is no update from InDesign or anything :'-(

tpk1982
Legend
August 22, 2017

Just check what the error it throws.. using try and catch method..

try{

    ExcelPath = new File("/D/Folder1/Folder_2/Folder3/file.xlsx");

}

catch(e){

    alert(e)

    }