Where do Extensions/App Scripts live?

68 views
Skip to first unread message

Zsolt Ero

unread,
Sep 11, 2025, 10:48:05 AM (13 days ago) Sep 11
to Google Apps Script Community
Hi,

When I make a one-off script for a Google Docs document, fixing formatting issues, where does it live/stay? I mean I click Extensions / App Scripts menu and make a script.

I see absolutely no way to find this script in Google Drive/Docs/web UI. I only find it when I open the same document again and go to it's Extensions menu and click Apps Script.

If these are indeed living "hidden inside" a Docs, how would you recommend me to store them properly? I mean I'm polishing a header/paragraph/table formatting script, and I definitely don't want to loose this now. Instead, I'd like to make sure it's a proper script which I can call from any of my docs.

How could I add it to the menu of all my docs?

Best regards,
Zsolt




Bennett, Scott

unread,
Sep 11, 2025, 10:51:21 AM (13 days ago) Sep 11
to google-apps-sc...@googlegroups.com
script.google.com is where they are.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/b71df2a6-f53b-4896-afe9-86a18365a2c9n%40googlegroups.com.


--
Scott Bennett


Keith Andersen

unread,
Sep 11, 2025, 10:52:34 AM (13 days ago) Sep 11
to google-apps-sc...@googlegroups.com
If you truly want it to be available for all other documents then you need to create it as a stand-alone script and then import it as a library into whatever document you want it to work on.



My website: https://sites.google.com/view/klaweb/
Passions: God, Family, Scriptures, Learning, Data Management, Google Sheets + App Script and much more!

Zsolt Ero

unread,
Sep 11, 2025, 11:21:59 AM (13 days ago) Sep 11
to google-apps-sc...@googlegroups.com
Thanks for your answers. 

I figured out what I need is actually an Editor Add-On, so it creates a menu item.

Here is what I did so far:


Pasted in this modified code:

function onOpen() {
DocumentApp.getUi()
.createMenu('My Formatting')
.addItem('Apply Custom Formatting', 'applyCustomFormatting')
.addToUi();
}

function applyCustomFormatting() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
// Set the font for the entire document to Inter
body.editAsText().setFontFamily('Inter');
// Get all paragraphs in the document
var paragraphs = body.getParagraphs();
// Format all paragraphs
for (var i = 0; i < paragraphs.length; i++) {
var paragraph = paragraphs[i];
// Skip paragraphs inside table cells, they are handled later
if (paragraph.getParent().getType() === DocumentApp.ElementType.TABLE_CELL) {
continue;
}

var text = paragraph.editAsText();
text.setFontFamily('Inter');
paragraph.setLineSpacing(1.15);
var heading = paragraph.getHeading();
if (heading === DocumentApp.ParagraphHeading.HEADING1) {
text.setFontSize(18); text.setBold(true);
paragraph.setSpacingBefore(24); paragraph.setSpacingAfter(12);
} else if (heading === DocumentApp.ParagraphHeading.HEADING2) {
text.setFontSize(16); text.setBold(true);
paragraph.setSpacingBefore(18); paragraph.setSpacingAfter(9);
} else if (heading === DocumentApp.ParagraphHeading.HEADING3) {
text.setFontSize(14); text.setBold(true);
paragraph.setSpacingBefore(14); paragraph.setSpacingAfter(7);
} else if (heading === DocumentApp.ParagraphHeading.HEADING4) {
text.setFontSize(12); text.setBold(true);
paragraph.setSpacingBefore(12); paragraph.setSpacingAfter(6);
} else if (heading === DocumentApp.ParagraphHeading.HEADING5) {
text.setFontSize(10); text.setBold(true);
paragraph.setSpacingBefore(10); paragraph.setSpacingAfter(5);
} else {
text.setFontSize(10);
}
}
// Handle tables
var tables = body.getTables();
for (var i = 0; i < tables.length; i++) {
var table = tables[i];
var numRows = table.getNumRows();
for (var row = 0; row < numRows; row++) {
var tableRow = table.getRow(row);
tableRow.setMinimumHeight(0);
for (var cell = 0; cell < tableRow.getNumCells(); cell++) {
var tableCell = tableRow.getCell(cell);
tableCell.setPaddingTop(1); tableCell.setPaddingBottom(1);
tableCell.setPaddingLeft(10); tableCell.setPaddingRight(10);
var numCellChildren = tableCell.getNumChildren();
for (var child = 0; child < numCellChildren; child++) {
if (tableCell.getChild(child).getType() === DocumentApp.ElementType.PARAGRAPH) {
var cellParagraph = tableCell.getChild(child).asParagraph();
var cellText = cellParagraph.editAsText();
cellText.setFontFamily('Inter');
cellText.setFontSize(8);
cellParagraph.setLineSpacing(1.0);
}
}
}
}
}
}



with this json:
{
"timeZone": "Etc/UTC",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"addOns": {
"common": {
"name": "My Custom Doc Formatter",
"useLocaleFromApp": true
},
"docs": {}
}
}




I clicked Deploy / Test Deployments. Here Editor Add-Ons and Google Workspace Add-On seems to do the same thing. I clicked Install in Editor Add-On.

Everything seemed OK, but nothing is visible in a Google Docs document's menu.

What did I miss? How can I debug these kind of issues? Where would I even look for debug log lines for the onOpen() part of an app script? Can I do something like what alert() would be in JS, just so I can see if the script is even run?

Zsolt





You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/5_puXGMQ834/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/CAFKgK%2BFrQr-o46374kjRONS3uqks%2BR%2BACUJ5PnU2t7Yhp9%2BGGw%40mail.gmail.com.

Keith Andersen

unread,
Sep 11, 2025, 11:37:32 AM (13 days ago) Sep 11
to google-apps-sc...@googlegroups.com
Keep in mind - you have it bound to that document only. If you want it in another document you will have to open this document, copy and paste everything into the new document.

If you make it a standalone script, you will still have to incorporate it into any new document by importing the library and writing a short code to run the function on open. 

Both will require some action on any new document. What's nice about the standalone script is that if you accidentally delete the first document or discard it because it's no longer needed - Your script goes with it too. 

Just FYI



My website: https://sites.google.com/view/klaweb/
Passions: God, Family, Scriptures, Learning, Data Management, Google Sheets + App Script and much more!

Zsolt Ero

unread,
Sep 17, 2025, 6:09:22 PM (7 days ago) Sep 17
to google-apps-sc...@googlegroups.com
Thanks. I'll definitely move it to a standalone script. What I'm wondering is if I could make it into an Editor Add-On, so that I have a menu item for all my documents.

I couldn't figure this out. Is it possible?

Zsolt



Reply all
Reply to author
Forward
0 new messages