This is a sample Google Apps Script designed to replace all instances of specific text within a Google Slides presentation, while simultaneously applying a desired text style. The built-in Presentation.replaceAllText() method within the Google Slides service is limited; it efficiently replaces text strings but lacks the functionality to modify text formatting during the replacement process. This limitation poses a challenge when aiming for styled text replacements. This report presents a detailed script solution that overcomes this constraint.
Have you ever needed to replace text across your Google Slides presentation but also wanted to apply specific formatting to the new text at the same time? The standard replaceAllText() method in Apps Script is handy for bulk text replacement, but it falls short when you need to control the styling – like font, size, or colour – during the replacement process.
Community contributor Kanshi Tanaike has developed a clever solution to overcome this limitation. Tanaike has shared a Google Apps Script function that not only finds and replaces text throughout all elements in your slides (including shapes, tables, and grouped objects) but also applies your desired text styles simultaneously.
The script works by iterating through the elements on each slide. When it finds the text you want to replace, it uses TextRange methods to perform the replacement and apply the specified formatting attributes, such as font family, size, colour, bold, italics, underline, and more.
This approach provides significantly more control than the built-in method, allowing you to ensure that automatically replaced text matches the exact styling you need for visually consistent and polished presentations. Tanaike’s post includes the full script, configuration details for specifying the text and styles, and sample slides showing the results.
Gemini API now generates images via Flash Experimental and Imagen 3. This report introduces image evolution within conversations using Gemini API with Google Apps Script.
The Gemini API recently gained the ability to generate images. Taking this a step further, Kanshi Tanaike has explored how to create evolving images within a conversation using Google Apps Script.
Often, you might want to generate an image and then iteratively add or modify elements in subsequent steps. Kanshi’s approach cleverly uses the chat functionality of the Gemini API (gemini-2.0-flash-exp model). By sending prompts sequentially within a chat, the API uses the conversation history, allowing each new image to build upon the previous one. This enables the generation of images that evolve step-by-step based on your prompts, as demonstrated in the original post with examples like drawing successive items on a whiteboard.
This technique is particularly useful because, as noted in the post, using chat history provides better results for this kind of sequential image generation compared to generating images from isolated prompts.
Kanshi Tanaike’s original post includes a detailed explanation, setup instructions (including API key usage and library installation ), and complete sample code snippets that you can adapt for your own Google Workspace projects.
The data reveals a notable decrease in Stack Overflow activity related to Google Apps Script from 2023 to 2024. There’s a reduction in total questions, questioners, answerers, and tags used. Interestingly, the ratios of answered and solved questions have increased. This suggests that while there’s less activity, a higher proportion of questions are getting resolved. A key factor influencing these trends is likely the rise of generative AI.
The latest report on the google-apps-script tag on Stack Overflow, published by Kanshi Tanaike, paints a fascinating picture: Google Apps Script is a maturing platform, but it’s also undeniably at a critical juncture. As Tanaike notes, “the rise of generative AI” is reshaping the developer landscape, and this is clearly reflected in the data.
The declining volume of basic Google Apps Script questions on Stack Overflow is arguably not a sign of the platform’s decline, but rather a signal of a significant evolution. This shift demands our attention and a willingness to explore the new opportunities and challenges it presents. This means actively seeking out new opportunities, adapting our skillsets, and rethinking traditional approaches to Google Apps Script development.
I believe the future of Apps Script rests on the skills of its developers and the strength of its community. Fostering a community capable of tackling complex integrations, building sophisticated automation within Google Workspace, and leveraging AI to enhance Apps Script’s capabilities is paramount. Supporting both current and new Apps Script developers, enabling them to unlock the platform’s full potential, is a key part of this future. The core value proposition, Apps Script’s unparalleled integration with the Google ecosystem, remains strong.
The real challenge, and the opportunity, lies in how the Google Apps Script community adapts, supporting knowledge sharing that goes beyond basic Q&A and cultivating a culture of deep understanding, critical thinking, and collaborative problem-solving. For us at AppsScriptPulse, this means continuing to share not just code snippets, but also design patterns, architectural best practices, and strategies for effectively integrating and evaluating AI-generated code.
Google Apps Script automates tasks like managing protections in Google Spreadsheets. These protections control user access to specific cells. While scripts exist for this purpose, users still encounter challenges, prompting this report. The report aims to introduce techniques for managing protections using sample scripts, helping users understand and implement this functionality.
Google Sheets aficionados are likely no strangers to the “Protect sheet” and “Protect range” options tucked away in the menus. These features offer a basic level of control over who can edit what within your spreadsheet. But what if you need more dynamic, automated control over these protections? That’s where the power of Google Apps Script and the Sheets API comes into play.
This post from Kanshi Tanaike provides a deep dive into how you can programmatically manage protections in your Google Sheets. While the traditional menu options are great for static scenarios, using Google Apps Script allows you to create more flexible and powerful protection workflows.
Why Go Script?
Dynamic Protections: Instead of manually adjusting protections, you can use scripts to change them based on specific conditions or events within your spreadsheet.
Automation: Integrate protection changes into larger automation workflows, streamlining processes and reducing manual intervention.
Granular Control: Achieve a level of control over cell-level permissions that goes beyond the standard menu options.
Some possible use cases for developers could include:
Approvals Automation: Imagine a scenario where certain parts of a spreadsheet need to be locked down once a manager approves them. With this solution, you could create a script that automatically protects those ranges upon approval.
Time-Limited Editing: Need to open up a section of a spreadsheet for editing only during a specific window of time? You could use Google Apps Script to handle this, automatically protecting
The scripts provided by Kanshi Tanaike offer a starting point for exploring these possibilities.
Google Apps Script offers Document service for basic document tasks and Google Docs API for advanced control, requiring more technical expertise. This report bridges the gap with sample scripts to unlock the API’s potential.
Kanshi Tanaike’s latest blog post, “Unlocking Power: Leverage the Google Docs API Beyond Apps Script’s Document Service,” is a great read for Google Workspace developers. It offers a goldmine of code snippets that will supercharge your Google Docs projects. Tanaike highlights the advantages of using the Google Docs API for more advanced features and flexibility compared to the standard Apps Script DocumentApp Service. Even though the API requires a bit more technical know-how, Tanaike provides clear, practical examples to get you started.
Some of the sample snippets include:
Changing page orientation (portrait to landscape and vice versa)
Kanshi Tanaike’s post serves as a valuable resource for developers looking to expand their Google Docs capabilities. Hopefully with these sample scripts, you can start unlocking new levels of automation and customization in your Google Doc projects.
To delve deeper into the world of Google Docs API, follow the source link post.
This is a Google Apps Script library including useful scripts for supporting to development of applications by Google Apps Script. In the current stage, the 3 categories “For array processing”, “For binary processing”, and “For string processing” are included in this library.
Google Apps Script developers often find themselves grappling with repetitive tasks particularly when handling Google Sheets data like array manipulation and A1 notation handling. Fortunately, this little versatile library from Kanshi Tanaike called UtlApp is here to help you simplify many of these common challenges.
Array Processing Made Easy
UtlApp includes a number of powerful array processing methods that can significantly streamline your code. Need to rearrange your data? The transpose method makes it effortless to flip your rows and columns. Want to extract specific data points? getSpecificColumns allows you to pinpoint and retrieve the exact columns you need. Dealing with large datasets? Quickly identify the first empty row or column using get1stEmptyRow and get1stEmptyColumn. And when it’s time to convert your array data into a more structured format, convArrayToObject can transform it into a JSON object, ready for further manipulation or integration.
Simplifying String Processing
UtlApp helps with common string processing tasks specifically for Google Sheets users. With columnLetterToIndex and columnIndexToLetter, you can convert between column letters and indices, making it simpler to work with spreadsheet data. UtlApp also offers convenient methods for managing A1Notations, such as consolidating scattered ranges using consolidateA1Notations or expanding them with expandA1Notations.
Handling Binary Data
UtlApp doesn’t stop at arrays and strings; it can also handle Blobs with the blobToDataUrl method. This function can convert Blob data into a convenient data URL format, making it suitable for embedding images or other binary content directly within HTML or CSS. This simplifies the process of working with Blobs in web-based Google Apps Script applications.
Effortless Integration
Adding UtlApp to your Google Apps Script project is a breeze! You have three convenient options: add the library directly using its project key, copy the individual script source files for array, binary, and string processing or copy individual functions into your project.
To find out more follow the source link to the GitHub repository.
This report proposes a novel learning method using Gemini to automate Q&A generation, addressing the challenges of manual Q&A creation. By integrating with Google tools, this approach aims to enhance learning efficiency, accessibility, and personalization while reducing costs.
The rapid advancement of technology has offered both opportunities and challenges to the education sector. While technology can be a valuable tool for supporting teaching and learning, concerns about its appropriate use have existed for a long time.
The education sector is witnessing an increase in AI tools, each promising to enhance teaching and learning. However, the quality of these tools varies significantly. Some are better designed and can – if used appropriately – can be beneficial, while others are poorly designed. This can make it challenging for educators to find the right solutions that meet their specific needs.
This blog post by Kanshi Tanaike sheds light on the inner workings of some commercial AI tools developed for educators. It demonstrates how these tools can use generative AI to create multiple-choice questions (MCQs) on a given topic. In this particular solution, Google Forms are used in the process, with questions and answers automatically generated by the Gemini API for the user to answer in a Google Form.
For educators who have experience with Google Apps Script, this project looks like a useful starting point to refine and create your own solution or simply used to gain insights into the functioning of similar commercial tools.
Great news for fans of both Google Docs and Markdown! Google Docs recently acquired the ability to export documents directly into the markdown format.
This functionality extends beyond the user interface, with early indications suggesting the Google Drive API might also be capable of converting between Google Docs and Markdown. I confirmed that this could also be achieved by Drive API. This opens exciting possibilities for automated workflows.
Google recently announced in July 2024 that import and export Markdown in Google Docs. This is a user facing features, which Google announced includes the ability to:
Convert Markdown to Docs content on paste
Copy Docs content as Markdown
Export a Doc as Markdown (from File > Download)
Import Markdown as a Doc (from File > Open or “Open with Google Docs” from Drive)
Kanshi Tanaike hasn’t wasted any time in unpicking Markdown conversion capabilities using the Google Drive API. This functionality enables automated workflows for converting between Google Docs and Markdown. There are various scenarios where this can be useful, in particular, given GenAI solutions like the Gemini API often generate markdown there are opportunities to automatically convert these to Google Docs.
As part of the source post there are sample scripts: one for converting Google Docs to Markdown and another for converting Markdown to Google Docs.
For the Markdown to Google Docs it is assumed that there is already a Markdown file in Google Drive. If you have a Markdown text as a string, for example from a Gemini API response, then you can create a formatted Google Doc using the following snippet designed to be used with v3 of the Google Drive Advanced Service:
function sample3() {
// note string is tab sensitive (tabs are converted to code blocks on certain Workspace accounts)
const sampleText = `sample text 1
| a1 | b1 | c1 |
| :---- | :---- | :---- |
| a2 | b2 | c2 |
sample text 2
* sample option1
* sample option2
* sample option3
sample text 3`;
const blob = Utilities.newBlob(sampleText, 'text/markdown');
const fileMetadata = {
name: `Sample MD Conversion`,
mimeType: MimeType.GOOGLE_DOCS,
};
Drive.Files.create(fileMetadata, blob, { supportsAllDrives: true });
}
An illustration which includes the Google Drive logo. The illustration includes a filing cabinet overflowing with files
This report provides a Google Apps Script to retrieve all files, including those within subfolders, for a designated folder. It addresses the challenges of retrieving files within deeply nested folder structures and obtaining complete file paths.
We’ve shared a couple of approaches to Google Drive reporting using Apps Script in Pulse, this latest comes from Kanshi Tanaike. There are actually two approaches covered in the post one using DriveApp and the other using the Drive API.
Hopefully, the related posts list on Pulse will highlight some of the alternative approaches you can use. I’m slightly obsessed with the .getFileNameWithPath() methods. This isn’t something that is provided in the Google Drive File resource data so it has to be constructed using only the file and parent information so it is interesting to see how this has been approached.
If you are looking at these code examples and struggling to understand them, Gemini (including implementations on gemini.google.com or aistudio.google.com), is a great way to copy the code (even the entire blog post) and start asking questions.
In February 2024, Google made a change in Google Sheets to enhance data security. Now, users must provide explicit consent before Sheets can connect to external data sources. This change aims to prevent unintentional data leaks and improve overall data loss prevention within Google Sheets.
Impact on Users:
When manually adding or editing certain IMPORT functions (IMPORTHTML, IMPORTXML, IMPORTFEED, IMPORTDATA) and the IMAGE function in a Google Sheet, a warning banner will appear blocking sending a receiving data until the user gives consent. To enable this functionality, users need to click “Allow access.”
Impact on Developers:
As highlighted in the first source post by Justin Poehnelt, this change caused issues for developers who programmatically create Google Sheets and automate tasks, such as generating PDF documents as the IMPORT and IMAGE functions were blocked.
Solutions for Developers:
Fortunately, Google introduced an update to the Google Sheets API to address this challenge. Developers can now enable external data access programmatically by setting the importFunctionsExternalUrlAccessAllowed property in the Google Sheet metadata. This allows specific IMPORT and IMAGE functions to work without manual user consent.
For the IMPORTRANGE function, a similar API property is currently unavailable. However, an unofficial workaround exists that involves calling an undocumented endpoint using Google Apps Script as detailed in the second source post by Kanshi Tanaike.
Future Expectations:
As Google continues to prioritize data security, there will likely be further enhancements to data loss prevention controls within Google Workspace. Hopefully, future updates will also include official API controls for IMPORTRANGE and other functions to facilitate legitimate data access for developers while maintaining data security.