Reputation: 555
I am trying to copy a Google slide into a Drive folder. When I run the script it looks like my two variables for destination and source are not defined. What am I missing?
function makeCopy() {
var name = SlidesApp.getActivePresentation().getName() + " Copy ";
var destination = DriveApp.getFolderById("1234567890");
// gets the current Google Sheet file
var source = SlidesApp.getActivePresentation();
// makes copy of "file" with "name" at the "destination"
source.makeCopy(name, destination);
}
Upvotes: 1
Views: 151
Reputation: 9571
SlidesApp.getActivePresentation()
returns a Presentation, but .makeCopy(name, destination)
is a File method.
Instead of having source
store the presentation, use the presentation's ID to get the file and store it instead.
function makeCopy() {
var name = SlidesApp.getActivePresentation().getName() + " Copy ";
var destination = DriveApp.getFolderById("123j3GbzhSB3m8xG-MijssMkynXHxNanl");
// gets the current Google Sheet file
var source = DriveApp.getFileById(SlidesApp.getActivePresentation().getId());
// makes copy of "file" with "name" at the "destination"
source.makeCopy(name, destination);
}
Upvotes: 2