AI Use Cases
Browse
Sign in
GeminiApps Script
marketingdocumentationgeminiapps script

Automating Document Styling with Gemini & Apps Script

Michael OApr 24, 2026

The Challenge

I was faced with a data-heavy report that required precise, systematic formatting. The goal was to identify every percentage and specific key phrases (like "90%", "United Kingdom" and "surveyed nations") to apply bolding and color-coded highlights.

The Tools

Gemini (AI Collaborator): My lead engineer for writing and debugging the custom code. Google Apps Script: The engine that executes the code directly within Google Docs.

The Workflow

Prompting for Logic: I described my visual requirements to Gemini. I needed a script smart enough to distinguish between a year (like 2026) and a data point (like 77%). Iterative Refinement: When the initial code missed certain phrases due to "ghost characters" or case-sensitivity, I fed the logs back to Gemini. We iterated until we had a "Master Script" that handled all rules simultaneously. Deployment: I pasted the JavaScript into the Apps Script editor and hit "Run."

The Result

The script ensured 100% accuracy, catching every instance of "UK" and every percentage point with zero oversight. By automating the "grunt work," I shifted my focus from manual formatting to high-level document review.

Bottlenecks & Challenges

  • The "Literal" Machine: Code is more literal than a human. We had to use Regular Expressions (Regex) to account for non-breaking spaces and varying capitalisations that the standard search bar usually ignores. Gemini handled all this.
  • Permissions: Google’s security requires a manual bypass to run custom scripts, which can be a slight hurdle for first-time users.
  • UI Refresh: Since the script runs in the background, the document occasionally needs a manual refresh or a scroll to visually reflect the new highlights.

Without AI, this would have meant using Ctrl+F over 150 times, manually selecting text with a mouse, and toggling styles for each instance. This "manual way" was a recipe for eye strain and human error; missing even a few percentages would undermine the document's professional consistency. I estimated the manual task would have eaten up at least 90 to 120 minutes of tedious clicking.

Bottom line:

The best way to go about this is to ask Gemini first if it can actually build an app script for the goal you want to accomplish. If it says yes, then you proceed to have it built.

Discussion

Comments (0)

Sign in to leave a comment.

No comments yet. Be the first to share your thoughts!