How to charge multiple Docs white a Script and a Library (An ID of a Standalone Script )?
function GetListFilesInFolder() {
var files = DriveApp.getFolderById("IDFOLDER").getFiles();
while (files.hasNext()) {
var file = files.next();
Logger.log(file.getName());
var doc = DocumentApp.openById(file.getId());
}
PUT HERE THE ACTION TO DO ( Mettre ici les modifs a effectuer )*
THE SCRIPT TO DO TO PASTE ID LIBRARY AND VERSION AND ALSO PASTE SCRIPT "Menu Library" IN EACH DOCUMENT *
-> Paste THE SCRIPT "Menu Library" AND ERASE EXISTING SCRIPT IF PRESENT
The key TO PASTE "KEY ID OF THE STANDALONE SCRIPT" ex :"MsyugbZjzwbREFX21kTravXXXXXx3oCoSL"
- Resources
- Library
- Search for a Library
-> Paste ID ( The key TO PASTE "KEY ID OF THE STANDALONE SCRIPT" )
- Select
- Set in a version V1 SCRIPT "biblio"
- Menu Manage Versions "V1"
- Save
-Save and close files
Logger.log("Done")
}
Version 3 11/07/2014 (2 Functions) {oninstall function () {onOpen (); onOpen} / / /function () {biblio.oninstall ();}"} Put only the functions in the "Biblio" Standalone Script
SCRIPT library "biblio" is called library, it is Unique It contains all the menus to create and execute Functions It is Unique and Key ID MsyugbZjzwbREFX21kTravXXXXXx3oCoSL Save a Version "V1" for example in File menu Manage Versions
SCRIPT of Appeal "Menu Library" is the same in all my Google Docs Document + + + + This script exactly HERE + + + +
In this SCRIPT "Menu Library " The key is entered MsyugbZjzwbREFX21kTravXXXXXx3oCoSL - Resources - Library
- Search for a Library -> Paste ID
- Select
- Set in a version V1 SCRIPT "biblio" Previously
Menu Manage Versions "V1"
This SCRIPT "Menu Library" Call the SCRIPT library The update of this script will be effective on all Documents Calling the Script "biblio" V1
All my Google Docs Document contains the script call "Menu Library" which call Unique Script "Biblio" Benefit: Getting a single day, once the "Biblio" In all Operational Documents Drive (featuring Script "Menu Library") ` All my new Google Docs documents are a copy of a Virgin with the Script File Type "Menu Library "
++++++++++++++++++++++++ Container-bound SCRIPT ON EACH DOCUMENTS ++++++++++++++++++++++++
function oninstall() {
onOpen();
}
function onOpen() {
biblio.oninstall();
}
/** ++++++++++++++++++++++++ STANDALONE SCRIPT biblio ++++++++++++++++++++++++ */
function onOpen() {
// Add a menu with some items, some separators, and a sub-menu.
DocumentApp.getUi().createMenu('OAR ..')
.addItem('MAJ Date + OAR', 'biblio.test')
.addItem('MAJ Date Auto', 'biblio.testdate')
.addItem('Ajout Texte QSP 28 OAR 2 Fois', 'biblio.AjoutQSP28JoursOAR2fois')
.addItem('URL Auto', 'biblio.urlauto')
.addItem('Macro en Cours ....', 'biblio.macroencours')
.addToUi();
DocumentApp.getUi().createMenu('Données Patients ..')
.addItem('Poids', 'biblio.message2')
.addItem('Age', 'biblio.message2')
.addItem('Taille', 'biblio.message2')
.addToUi();
DocumentApp.getUi().createMenu('Ordo Paramedical ..')
.addItem('Accès Ordo Paramedical', 'biblio.accesordoparaA4')
.addItem('Accès Ordo Paramedical ALD', 'biblio.accesordoparaA5')
.addToUi();
}
function message2() {
DocumentApp.getUi() // Or DocumentApp or FormApp.
.alert('Laurent inove tjrs et encore ! Developpement en Cours ... Récupération des Données / Fiches Patients ... Soyez Patients !!!');
// a creer
}
function urlauto() {
DocumentApp.getUi() // Or DocumentApp or FormApp.
.alert('Developpement en Cours ... Veuillez Patientez ... Laurent travaille Déjà Beaucoup !');
// a creer
}
function AjoutQSP28JoursOAR2fois() { //Ajout QSP 28 Jours + OAR 2 fois
var doc = DocumentApp.getActiveDocument();// or DocumentApp.openById(file.getId()); as in your example code
var element = doc.getBody().findText("Le");
var d=new Date();
var s3=d.getFullYear();
var s2=d.getMonth()+1;
var s1=d.getDate();
var s4 =s2+2
var s5 =s1-10
var s6 =s2+3
if(s1<10) {
s1=("0"+s1).slice(s1.length-1);
}
if(s1>10) {
s1=(""+s1).slice(s1.length-1);
}
if(s2<10) {
s2=("0"+s2).slice(s2.length-1);
}
if(s2>10) {
s2=(""+s2).slice(s2.length-1);
}
var start = element.getStartOffset();
var text = element.getElement().asText();
text.editAsText().deleteText(3,12);
text.replaceText("Le ","Le " +[s1,s2,s3].join('/') + "\n" + "\n" +"QSP 28 Jours" +"\n"+ "OAR 2 fois");
text.editAsText().setFontSize(14,38,12);
}
function accesordoparaA4() {
DocumentApp.getUi() // Or DocumentApp or FormApp.
.alert('Developpement en Cours ... Veuillez Patientez ... Laurent travaille Déjà Beaucoup !');
// Open a document by ID.
var doc = DocumentApp.openById("");
}
function accesordoparaA5() {
DocumentApp.getUi() // Or DocumentApp or FormApp.
.alert('Developpement en Cours ... Veuillez Patientez ... Laurent travaille Déjà Beaucoup !');
}