Here’s a Google Apps Script that scans a Google Docs document and bolds specific words (Objective
, Code
, and Explanation
) when they appear on their own lines.
Features:
- Searches for the words Objective, Code, and Explanation when they are on their own lines.
- Applies bold formatting to these words.
- Works for any Google Docs document.
Google Apps Script:
function boldSpecificWords() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var paragraphs = body.getParagraphs();
var wordsToBold = ["Objective", "Code", "Explanation"];
paragraphs.forEach(paragraph => {
var text = paragraph.getText().trim();
if (wordsToBold.includes(text)) {
paragraph.setBold(true);
}
});
Logger.log("Specified words have been bolded.");
}
How to Use:
- Open a Google Docs document.
- Click Extensions > Apps Script.
- Paste the script into the editor.
- Click Run.
- Authorize the script when prompted.
- The words Objective, Code, and Explanation will be bolded if they are on their own lines.
