corrige cette macro Google document elle m'insère un titre avec 1 au lieu de voir le…
- User
corrige cette macro Google document elle m'insère un titre avec 1 au lieu de voir le dernier titre inséré comme 478 et de l'incrémenter et donc mettre 479 "/**
-
Inserts a new dated title at the top of the document and then */ function insertNewEntryAtTop() { try { var doc = DocumentApp.getActiveDocument(); var body = doc.getBody();
// Prepare new title text. The number is just a placeholder. var today = new Date(); var formattedDate = Utilities.formatDate(today, Session.getScriptTimeZone(), 'dd/MM/yyyy'); var titleText = '1 - ' + formattedDate;
// Insert the title and a blank paragraph at the very top. var titleParagraph = body.insertParagraph(0, titleText); titleParagraph.setHeading(DocumentApp.ParagraphHeading.TITLE); var newParagraph = body.insertParagraph(1, '');
// Move the cursor to the blank paragraph for immediate typing. var newPosition = doc.newPosition(newParagraph, 0); doc.setCursor(newPosition);
} catch (e) { DocumentApp.getUi().alert('Erreur', 'Impossible d'insérer la nouvelle entrée : ' + e.message, DocumentApp.getUi().ButtonSet.OK); } }"
-
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.