I attempted converting an autofill Docs script to produce Google Slides. Code using SlidesApp fails due to a missing copy method. How can I adjust the script to work with Slides?
Using a drive file copy is key. I ran into a similar issue when converting my Docs-based autofill script to work with Slides. Instead of seeking a copy method within SlidesApp, I leveraged DriveApp.makeCopy to duplicate the template presentation. Once the file was copied, I used SlidesApp.openById to modify the slides’ placeholders via replaceAllText. I found that ensuring the file duplication happened via DriveApp while managing slide details through SlidesApp resolved the error, allowing the script to work as intended.
I had to deal with a similar challenge while transitioning from Docs autofill to Slides generation. The workaround I discovered was to create a copy of the Slides template using DriveApp first, as the SlidesApp itself does not support a direct copy method. Once I created the duplicate, opening it with SlidesApp.openById enabled me to perform text replacements and other modifications using replaceAllText. My experience taught me that handling file duplication with DriveApp before editing significantly reduces compatibility issues and streamlines the overall process.
hav entered a slight pause before editing. driveapp.makecopy duplicates the slieds correctly, and then SlidesApp.openById works fine. i noticed a race condtion sometimes so a short delay can prevent copy lag issues.
My recent experiment with a similar task involved adding a brief delay after using DriveApp.makeCopy to ensure the new slide deck was fully accessible before modifications began. Introducing a short wait time resolved occasional issues where SlidesApp.openById seemed to clash with the duplication process. Additionally, I verified that placeholders in the template exactly matched the text to be replaced, as discrepancies led to overlooked substitutions. Testing with a subset of data also proved beneficial, allowing the script to run more reliably before processing a full data set.
I encountered the same challenge and found that verifying the availability of the file after duplication was crucial. By adding a brief wait time using Utilities.sleep, the system had enough time to register the copied file. This prevented recurring issues with SlidesApp.openById not finding the new file. I also ensured that the template placeholder names matched exactly what was specified in the replacement calls. These small adjustments, although sometimes overlooked, significantly improved the script’s stability during large data operations.