Copy link to clipboard
Copied
Hey all,
I'm fairly new to using scripts in InDesign, but I need to write one specifically for a catalog I'm working on. I have successfully imported all of the product information and images from a .csv file using data merge. Each page has 6 products, and each product takes up one row with four columns. I am needing to make a digital version of this catalog that allows the customer to click on the image of any product and have it lead them to that product on the company website.
I have all of the product urls in a .csv spreadsheet that are sorted accordingly to each product, but I am at a loss on how to write a script that will pull these urls from the spreadsheet and link them to the product images in the document.
I am using InDesign CC 2017, and Microsoft Excel for Mac Version 15.33
If anyone is able to help or even remotely point me in the right direction on what to do it would be greatly appreciated!!
All the best,
Megan
Copy link to clipboard
Copied
I think the Auto hyperlink script (by Nobrainer Scripting) may come in handy to you. You can save the csv-file as txt leaving only product names and URLs separated by tabs.
Copy link to clipboard
Copied
Hi Kasyan,
This script sounds perfect for the project I'm working on! I'm having some issues making it work though and was hoping you could help. If I'm keeping the txt filed named the exact same do I need to change anything in the script?
Thanks!
Monica
Copy link to clipboard
Copied
Hi Monica,
No, you don't have to interfere in the script; the user is supposed to edit the txt-file only.
However, if your project has some specific requirements, the script may need some adjustments.
Regards,
Kasyan
Copy link to clipboard
Copied
Hi Kasyan,
I'm getting the above error when I try and run the script... any ideas?
Thanks,
Monica
Copy link to clipboard
Copied
I guess you don't have the character style named "hyperlink" in the document.
— Kas
Copy link to clipboard
Copied
I do but I've had to manually put it in (it wasn't automatically in my character styles)
Monica
Copy link to clipboard
Copied
The script doesn't add it automatically. I'm not the author of the script so that's the way Nobrainer Scripting designed it.
— Kas
Copy link to clipboard
Copied
Hi Kas sorry hopefully last question!
So I've gotten the script to work on one of my indesign documents and was hoping to use it on another one but when I do I'm getting an error message saying "This name is already in use by another object" I have tried making a copy and changing the name of the jsx file as well as the txt file but am still getting the same error!
Monica
Copy link to clipboard
Copied
Hi Monica,
I remember I encountered and solved this problem in the past, but at the moment I can't recreate it.
Probably the document already has hyperlinks (e.g. you already run the script on it) and it attempts to use the found text (source) which is already taken by another hyperlink. You can't do this manually so it's impossible to do by script as well. The screenshot illustrates the situation:
But this is only my guess. I can't give you a more definite answer without seeing the document.
— Kas
Copy link to clipboard
Copied
I got it! Just had to make the hyperlinks character style all lower case! Thanks for the help!!
Monica
Copy link to clipboard
Copied
Hello here is a code that I started to regroup because I will also be led to do the same
Bonjour voici un code que j'ai commence à regroupé car je serai aussi amené à faire la même chose
var imgs = app.activeDocument.allGraphics; |
$.writeln (imgs.length);
for (var i = 0; i < imgs.length; i++) {
// imgs.verticalScale = 92; | |
//imgs.horizontalScale = 92; | |
//imgs.fit(FitOptions.FRAME_TO_CONTENT); | |
// imgs[0].parent.appliedObjectStyle = "LeStyle"; | |
// imgs[0].parent.applyObjectStyle( "LeStyle" ); | |
$.writeln(imgs.parent.appliedObjectStyle.name); | |
$.writeln(imgs.itemLink.filePath);// = app.activeDocument.objectStyles.itemByName("LeStyle"); // Faire controle | |
$.writeln(imgs.itemLink.name);// = app.activeDocument.objectStyles.itemByName("LeStyle"); // Faire controle | |
try{ | |
myHyperlinkURL = app.activeDocument.hyperlinkURLDestinations.add('http://www.apple.com'); | |
myHyperlinkSource = app.activeDocument.hyperlinkPageItemSources.add(imgs.parent); | |
myHyperlink= app.activeDocument.hyperlinks.add(myHyperlinkSource,myHyperlinkURL); | |
myHyperlink.visible=false; | |
} | |
catch(myError){ | |
} |
}//