Set hyperlink to cell contents with JavaScript
Hi all
I need to create hyperlinks to certain cell contents. The cells will have a script label, '1' in my example here, and it's always going to be in the first column of the table. I then have to add the content of the cell, which is always an article number, to the hyperlink, hence the + in the URLDestinations setting. Setting the Destination works and myCellData contains a text object which I think is correct. I think I'm almost there but adding the hyperlinkTextSources doesn't work and I can't figure out why.
my current code:
var myDoc = app.activeDocument;
var myCells = myDoc.stories.everyItem().tables.everyItem().cells.everyItem().getElements();
var mySource;
var myDest;
var myURL = 'https://myURL.com/';
for (var i = 0; i < myCells.length; i++){
if (myCells[i].label == '1') {
var myCellData = myCells[i].texts[0];
mySource = myDoc.hyperlinkTextSources.add(myCellData);
myDest = myDoc.hyperlinkURLDestinations.add(myURL+myCellData);
myDoc.hyperlinks.add(mySource, myDest, {name:myURL});
}
}Any help is much appreciated!
