0

I am automating the building of a document based on a set of inputs. I started with Google's example here: https://developers.google.com/apps-script/samples/automations/aggregate-document-content, and made modifications.

The problem I have is when one or more of the source documents contains a bulleted list. The list is imported into the new document as a bulleted list, which is what I expect, but there is no glyph for the list, so it just looks like indented text. I have to manually select each bulleted list and set the bullet style for the list.

Is there a way for me to specify the bullet style I want to be used for all bulleted lists one time, or in some way search for the bulleted lists with App Script after the import to find them and change them?

2 Answers 2

1

Setting Glyph Type:

function settingGlyphType() {
  var body = DocumentApp.getActiveDocument().getBody();
  body.appendListItem("Item 1");
  body.appendListItem("Item 2").setNestingLevel(1).setIndentStart(72).setGlyphType(DocumentApp.GlyphType.SQUARE_BULLET);
}

Enum GlyphYype

Sign up to request clarification or add additional context in comments.

1 Comment

Doesn't this change the glyph when you insert a new bullet point? In my case I am copying a block of text from another document, and that block of text may have one or more existing lists in it. I want to set the glyph on all of those lists after they are copied into my document.
1

Okay, I think I figured it out.

    function setGlyphType() {
        var body = DocumentApp.getActiveDocument().getBody();
        var bullet = null;
        while(bullet = body.findElement(DocumentApp.ElementType.LIST_ITEM, bullet)) {
            bullet.getElement().asListItem().setGlyphType(DocumentApp.GlyphType.BULLET);
        }
    }

The while loop searches the body for elements of type LIST_ITEM, starting from the last LIST_ITEM found. If an element of that type was found, change the GlyphType to BULLET.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.