且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法从文档中删除脚本(使用新的文档嵌入脚本)

更新时间:2023-12-05 19:12:46

Following Henrique's suggestion I used a workaround that prevents the UI to load on newly created documents... (thanks Henrique, that was smart ;-)

The function that is called by onOpen now goes like that :

function showFields() {
  var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  var find = body.findText('#'); // the new docs have no field markers anymore. 
  if(find != null){  // show the UI only if markers are present in the document.
  var html = HtmlService.createHtmlOutputFromFile('index')
      .setTitle("Outils de l'option Publipostage").setWidth(370);
  ui.showSidebar(html);
  }
}

相关阅读

推荐文章