To create a Google Apps Script that updates all paragraphs styled as “Normal text” in a Google Doc to have a font size of 11 and not be bold, follow these instructions. This script will go through your Google Doc and apply these formatting changes to all paragraphs that are designated as “Normal text.”
- Open Your Google Doc: First, open the Google Doc you wish to modify.
- Access Script Editor: Navigate to
Extensions
>Apps Script
to open the Apps Script editor. - Replace Script Content: In the Apps Script editor, remove any existing code and paste the following script:
function updateNormalTextParagraphs() {
var doc = DocumentApp.openById(DOCID);
var body = doc.getBody();
var paragraphs = body.getParagraphs();
paragraphs.forEach(function(paragraph) {
// Check if the paragraph's heading is NORMAL
if (paragraph.getHeading() === DocumentApp.ParagraphHeading.NORMAL) {
// Update the font size to 11 and make sure it's not bold
paragraph.editAsText().setFontSize(11).setBold(false);
}
});
}
- Save the Script: Click
File
>Save
, and give your project a suitable name. - Run the Script: To execute your script, click the play/run button (▶️) next to the
updateNormalTextParagraphs
function. If this is your first time running the script, you will be prompted to authorize it. - Authorize the Script: Follow the on-screen prompts to allow the necessary permissions for your script to run. You might encounter a warning indicating that Google hasn’t verified the app. This is expected for new scripts. To proceed, click on
Advanced
and thenGo to [YourProjectName] (unsafe)
, and agree to the permissions.
This script will iterate over all paragraphs in your document, and for those with the “Normal text” style, it will set the font size to 11 and ensure that the text is not bold.
It’s important to remember that you’ll need to run this script manually each time you want to apply these formatting changes to your document, as the script does not automatically trigger with text changes or additions.