P Suriya
P Suriya

Reputation: 31

How to fix "Exception: Unexpected error while getting the method or property open on object SpreadsheetApp"?

I have only pasted a part of the code which I am trying to run separately.

function myFunction() {
   var files = DriveApp.searchFiles('title contains "Companies_OHLC_0"');
   while (files.hasNext()) {
        var spreadsheet = SpreadsheetApp.open(files.next());
    }
 }

it was working sometime back but I keep getting this exception now:

Exception: Unexpected error while getting the method or property open on object SpreadsheetApp. (line 4, file "Code").

Upvotes: 1

Views: 3539

Answers (1)

P Suriya
P Suriya

Reputation: 31

I figured it out. I had multiple files with the same name and hence, i was getting that exception.

I had run other scripts which had created new files with the same names.I had not noticied this. I deleted all the duplciate files and I am not getting this exception any more.

Upvotes: 2

Related Questions