#I want to make a table/text that will be
1 messages ยท Page 1 of 1 (latest)
Thanks
Google Docs itself doesn't have a built-in feature to automatically update text or tables based on the day of the week. However, you can achieve this using Google Apps Script, which allows you to add custom functionality to Google Docs.
Hereโs a step-by-step guide to create a script that updates a specific text in a Google Docs document every Friday:
Step 1: Create a Google Apps Script
Open your Google Docs document.
Go to Extensions > Apps Script. This will open the Apps Script editor.
Step 2: Write the Script
Delete any code in the editor and paste the following script:
function updateTextOnFriday() {
// Open the Google Docs document by ID
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
// Get the current day of the week (0 = Sunday, 6 = Saturday)
var today = new Date();
var dayOfWeek = today.getDay();
// Specify the text you want to insert on Friday
var fridayText = "This is the updated text for Friday.";
// Specify the default text
var defaultText = "This is the default text.";
// Find and replace the placeholder text in the document
if (dayOfWeek == 5) { // If today is Friday
body.replaceText("{{PLACEHOLDER}}", fridayText);
} else { // For all other days
body.replaceText("{{PLACEHOLDER}}", defaultText);
}
}
Replace "{{PLACEHOLDER}}" in the code with a placeholder text of your choice that will be replaced in the document.
Step 3: Set a Trigger to Run the Script Every Day
In the Apps Script editor, click on the clock icon on the left sidebar to open the Triggers page.
Click on "Add Trigger".
Set the function to updateTextOnFriday.
Set the event source to Time-driven.
Choose Day timer and select a time when you want the script to run daily.
Save the trigger.
Step 4: Place the Placeholder in Your Document
Go back to your Google Docs document.
Insert the placeholder text (e.g., {{PLACEHOLDER}}) where you want the text to be updated.
Step 5: Save and Test
Save your script by clicking the floppy disk icon or pressing Ctrl + S.
Test your script by manually running the updateTextOnFriday function to see if it replaces the placeholder text based on the current day.
Now, the specified text in your Google Docs document will be updated automatically on Fridays, and it will show the default text on other days.
Well, I wanted to save the trigger, and I got this window
Nevermind! I solved this problem
great! ๐
That's how it should be, right?
I changed Friday on Sunday
Yup, that is correct, feel free to ask anything! I am here to help you ๐
So, I insterted the placeholder text.
Did I do it right?
Yes, it is correct!
Thank you sm it worked!