This content has been marked as final. Show 9 replies
CS2? CS3? Where can the number be found? At the beginning of each paragraph? At the end? Is it the only number in the paragraph or line?
I am using CS3
I am doing a data merge and the number is from a field in the table ... not sure if that helps at all ...
>the number is from a field in the table
Which field is that? I guess you mean "cell". So you have a table, and in each row there is a cell with a number in it, and that number needs to be replaced with some stars. Which cell is the number in? The first one?
The star rating cell is the fourth one
Here is a basic script (in the sense that it doesn't do much error checking). Place the cursor in the table you want to process and run the it.
// Exit if nothing is selected or when the cursor is not in a table
if (app.selection.length == 0 ||
app.selection.parent.parent.constructor.name != 'Table')
myCells = app.selection.parent.parent.columns.cells;
for (i = 0; i < myCells.length; i++)
stars = "";
rating = myCells[i].contents;
for (j = 0; j < rating; j++)
stars += '*';
myCells[i].contents = stars
Not sure this will do what I want though. I am performing a data merge and one of the fields in the merge is <<biz_stars>> and during the merge (if possible) I'd like the numeric value replaced with a graphic. For example if the biz_stars = 2 I'd like an image with 2 stars replacing the number and so on ...
Maybe you should have been more explicit in your first query. I don't think it's possible to insert graphics during the merge, but I never use merge so I don't know about that. You probably have to do it after the merge -- but that doesn't make much difference, does it?
Inserting the graphics makes the script more complicated. Maybe you should think of hiring someone to write it for you.
You could probably go 3 ways. Run a script after the merge, this would be the best.
For each page, get the number/integer of the star rating from the text box. Then have the script draw X number of image frames on the page where ever the rating needs to be, like 3 or 4 small square boxes. You'd have to manually determine the placement of box 1, box 2 etc. Then place a star graphic in each box.
Or you could also have the stars drawn as a polygon shape directly in InDesign, drawn as many times as needed.
Or draw just one box, long rectangle, and then have 5 images of star ratings, 1 star, 2 star etc. Based on the number, place the file name that begins with that number (ie "1-star.jpg").
I actually solved this by having the query for the data merge convert the star rating to characters (e.g. if the rating was a 2 the query printed HH) and then I used a font called "SORTS" which is similar to wingdings. H happens to be a star shape in that font. This solution worked perfectly without any scripting in InDesign, just a little scripting in Access which seems easier to code in.