Below is a Google Apps Script that selects all H3 paragraphs in a Google Document, converts them to regular paragraphs, and makes the text within them bold:
function convertH3ToBoldParagraphs() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var paragraphs = body.getParagraphs();
for (var i = 0; i < paragraphs.length; i++) {
var paragraph = paragraphs[i];
if (paragraph.getHeading() == DocumentApp.ParagraphHeading.HEADING3) {
// Get the text of the H3 paragraph
var text = paragraph.getText();
// Remove the H3 formatting
paragraph.setHeading(DocumentApp.ParagraphHeading.NORMAL);
// Replace the paragraph text with bold formatting
paragraph.clear().appendText(text).setBold(true);
}
}
}
Here’s how it works:
- It gets all the paragraphs in the document.
- It iterates through each paragraph, checking if it’s an H3 paragraph.
- If it finds an H3 paragraph, it retrieves the text, removes the H3 formatting, and sets the text to bold.
To use this script:
- Open your Google Document.
- Click on “Extensions” > “Apps Script.”
- Delete any code in the script editor and replace it with the provided script.
- Save the script.
- Run the function
convertH3ToBoldParagraphs
from the script editor.
This will convert all H3 paragraphs to regular paragraphs with bolded text.