Skip to main content
leeroyp35733778
Participant
January 15, 2024
Answered

Hyperlinking Script for a digital Planner

  • January 15, 2024
  • 4 replies
  • 840 views

Hi All,

 

I am working on creating a planner in  indesign. I have monthly pages with Google icons, which is an image. I want to ad an external links so it adds a date to the google calender. 

The links would like this: 
https://calendar.google.com/calendar/u/0/r/eventedit?action=TEMPLATE&dates=20240126/20240126

is there an easy way to do this please using a script and csv file? I have to do this 365 times.

This topic has been closed for replies.
Correct answer leeroyp35733778

I see, I had hoped Indesigns Script feature would be the answer to all. 

For now i'll try bugging around with ChatGPT to see if I can solve this, if not then I'll try the manual route. 

 

4 replies

Mike Witherell
Community Expert
Community Expert
January 15, 2024

Scripting and frame script labeling are a frustrating enterprise. Manual can get you done in less time.

Mike Witherell
leeroyp35733778
leeroyp35733778AuthorCorrect answer
Participant
January 15, 2024

I see, I had hoped Indesigns Script feature would be the answer to all. 

For now i'll try bugging around with ChatGPT to see if I can solve this, if not then I'll try the manual route. 

 

leeroyp35733778
Participant
January 15, 2024

Right now i'm trying to write a script with ChatGpt to give each of the google Images a script label, so that it's easier to then write another script that connects each google calender link to the correct script label with a csv file. 

But i can't get it to work. At the end of the script it selects each image and in the Script Label view I can see the new Script Label name gets added, then after the script is done and I deselect the image and reselt it, the Script label window is empty for all images and all script labels seems to be empty again. 

any advice on this?

var myDocument = app.activeDocument;
var myLayer = myDocument.layers.itemByName("GoogleLogos");
var myItems = myLayer.allPageItems;
var day = 1;

for (var i = myItems.length - 1; i >= 0; i--) {
var myItem = myItems[i];
if (myItem instanceof Image) {
var dayFormatted = ("0" + day).slice(-2);
var label = "google_" + "01" + "-" + dayFormatted;
myItem.label = label;

// Verify that the label is set
if (myItem.label === label) {
alert("Label successfully set for item " + i + ": " + label);
} else {
alert("Failed to set label for item " + i);
}

day++;
if (day > 31) {
alert("End of month reached.");
break;
}
}
}

for (var i = myItems.length - 1; i >= 0; i--) {
var myItem = myItems[i];
if (myItem instanceof Image) {
var dayFormatted = ("0" + day).slice(-2);
var label = "google_" + "01" + "-" + dayFormatted;
myItem.label = label;

// Select the item and pause the script
myDocument.select(myItem);
alert("Item " + i + " selected with label: " + label);

day++;
if (day > 31) {
alert("End of month reached.");
break;
}
}
}

 

brian_p_dts
Community Expert
Community Expert
January 15, 2024

Really depends on how the doc is built and the incons are associated (or not) to any containing box. Likely, based on your screenshot there is not much correlation, so you'd have to get pretty wild by writing an algorithm to sort the icons on the page and then associate them by date. Probablya script to handle a single page is most feasible since you likely have other nonmonth pages in between. Still not a trivial task. 

leeroyp35733778
Participant
January 15, 2024

I now have every image in a seperate layer called GoogleLogos, it's also in ascending order. So the first image in the layer is for jan 1th, the 15th image in the layer is for jan 15th. 

I've tried writing a script to give all the images a Script label, but I can't seem to get it working. 

Mike Witherell
Community Expert
Community Expert
January 15, 2024

Likely, you would have to do it manually, because each one must have the date unique to the calendar day.

Mike Witherell