Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9214623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:00:40+00:00 2026-06-18T02:00:40+00:00

My Question: How do you set text to be a title or subtitle in

  • 0

My Question: How do you set text to be a title or subtitle in a Google Doc using Google Apps Script? (see a visual example below)

In Google Apps Script documentation on formatting paragraphs they show the different types of ParagraphHeadings in the ParagraphHeading class and then there’s the Attribute class which can be assigned to a paragraph which has some styling attributes. However, neither of these has a way to set any text as a title or a subtitle in the document. How is that accomplished?

I’m looking for something like this:

var doc = DocumentApp.getActiveDocument();

// Append a paragraph, with title.
var par1 = doc.appendParagraph("Title");
par1.setHeading(DocumentApp.ParagraphHeading.TITLE);

// Append a paragraph, with subtitle.
var par2 = doc.appendParagraph("SubTitle");
par2.setHeading(DocumentApp.ParagraphHeading.SUBTITLE);

// Append a paragraph, with heading 1.
var par3 = doc.appendParagraph("Heading 1");
par3.setHeading(DocumentApp.ParagraphHeading.HEADING1);

Here’s what I mean:

Headings

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:00:42+00:00Added an answer on June 18, 2026 at 2:00 am

    The example script you get if you choose “Create script for… Document” doesn’t use setHeading() at all, instead it explicitly manipulates the WYSIWYG attributes. (I hate when people do that in documents, and I’m only slightly less annoyed by it in script, but that’s a topic for another day!)

    Example, lifted directly from that sample script, including bad grammar:

    function createDocument() {
      var title = 'Script Center Report';
      var summaryContents = 'This reports addresses...';
      var overviewContents = 'We undertook this project because...';
      var dataContents = 'We collected three samples of data...';
    
      var doc = DocumentApp.create(title);
      var footer = doc.getFooter();
    
      var reportTitle = doc.appendParagraph(title);
      reportTitle.setFontFamily(DocumentApp.FontFamily.ARIAL);
      reportTitle.setFontSize(24);
      reportTitle.setForegroundColor('#4A86E8');
      reportTitle.setAlignment(DocumentApp.HorizontalAlignment.CENTER);
      ...
    

    That’s just a work-around – if you haven’t done so already, you should create an issue report against apps-script to ensure all “Paragraph Types” are available to scripts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In below data list represents set of question's and answer, How to check whether
My question is: How to set NSIndexPath programmatically. For example I add method: -
In my markup I am using HTML title attributes which I set by the
The title of the question pretty much tells it all. When using the java
[ Old question title used to be ARC is set to YES, but xcode
Boring of googling this question - how to set indentation offset for python in
Question: What is the best way to set focus to a web control in
I have a question about how to set up the relations between two models
My question is : I have an EditText and I want set a margin
My question is regarding this post Is it possible to set an animated gif

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.