When creating heading levels in a document, it’s easy to get confused about which level a paragraph should be at. If you reduce a header level, the headings below need to be adjusted also, and its not till you come to creating a contents page that you notice it’s all out of line.

Here’s a snippet to adjust header levels so that sub headings are never more than one deeper than the previous header.

Adjusting heading levels

This one provides a dry run capability, where the log file tells you what it would have done. Set it to false when you are ready to go for real.

The code

For more like this see Google Apps Scripts Snippets
Why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.