Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Although GREP is primarily a text- based feature, you can actually use GREP to insert graphics too. By combining GREP Find/Change, Styles and Anchored objects, we're going to see how you can insert hundreds of anchored object frames in mere seconds. To finish off the layout of this directory of embassies, I want to add before each country name, a small graphic frame into which artwork for the flag of that country is going to be placed. They are going to go in as anchored objects, so that they flow with the text and they all appear in the same place above each line.
So the first thing I'm going to do is create a graphic frame for myself as a placeholder to receive those files when I'm ready to place them. I will draw a frame out here with the Frame tool, roughly the size and dimensions of a small flag. I'll switch to the Selection tool and then from the Edit men, choose Cut to copy it to the Clipboard. I'm going to put my cursor in at the beginning of the very first letter in the very first country in this list and then I'll go to Edit>Paste to insert that object and by default, it goes in as an inline anchored object.
I will switch back to the Direct Selection tool, click on the Graphic frame and then right-click and go to Anchored Object>Options. By default, this is an Inline object that sits to the left of the text. I actually want to make it an Above Line object so that it sits above that line and I want to add a little space after it, so I am just going to notch that up in the Space After field and that's about what I want. I will click OK and now that I've got this positioned and anchored exactly the way I want, I want to save all of those settings as an Object Style.
From the Window menu, I'll choose Objects Styles and I'm going to create a New Object Style by choosing that option from the panel menu. I'll name this object style 'Anchored Flags' and then I'll go over the Anchored Object Options for this style and we can see that what I just did, has been picked up and built into the style automatically. I'm going to add one more feature in here. I'm going to activate Frame Fitting Options. I want to make sure that whatever graphics get placed in these frames, when I am ready to take that step, will fit proportionally in that frame, so I will choose Fit Content Proportionally.
That's going to resize the graphics as they are placed. One last thing I want to do though is go to General and make sure that Apply Style to Selection is on, so that when I click OK, you can see that the selected object, which I already pasted, has Anchored Flags applied to it automatically. I'll close Object Styles because I am done with that and then I'll select this frame again and I'm going to cut it to the Clipboard. Now that that frame is in the Clipboard, I'm going to start inserting it everywhere that I need it using Find/Change and GREP.
I will hit Command+F, or Ctrl+F, on Windows to open the Find/Change dialog. I'm in the GREP tab, but I want to make sure that I click More Options because I'm going to want to describe formatting as a search criteria to make this work. Before I start entering anything in the Find what field, let me think about exactly what I'm trying to do. I have something in my Clipboard. I want to insert that object that's copied to the Clipboard at the beginning of every line that's using the Country Paragraph Style.
I know that I need to describe a location at the beginning of a paragraph, which I can do with the caret metacharacter. Because a location can't actually be changed, this isn't enough for me to carry out what I need to do. I also need to describe the first letter at the beginning of that paragraph. But I'm going to need to remember what that letter is and ask for it back again when I'm ready to make my changes. So I'm going start a Marking Subexpression with an opening parenthesis and put the any character meta character in it and close off the Subexpression with a closing parentheses.
So I'm asking for one single character that exists at the beginning of a paragraph but not any paragraph, only paragraphs that use the Country Paragraph Style. So I need to go down and specify formatting attributes to find. Click this icon here and I'm going to select my Country Paragraph Style and click OK. Now I've defined any character at the beginning of a line using the Country Paragraph Style. So, I'm ready to start writing my Change Expression.
What I'm trying to insert is a Graphic Frame. I've copied it to the Clipboard, but I can't just paste it into the Change to field. It doesn't work that way. However, there is a little known meta character in both Text Find/Change and GREP Find/Change that I can use to accomplish the same thing. From the Special characters for replace menu, I'll go to the Other submenu and I'm going to choose Clipboard Contents, Formatted. This is the only way, in InDesign, where you can actually use Text-based Find/Change to put in anything you want.
It could be a Graphic Frame, like I'm trying to do. It could be a Stroke. It could be another Text Frame. It could be anything that's copied to the Clipboard. So I will choose Clipboard Contents, Formatted. It puts in the tilde C meta-character. But I also want to recall the first letter that I defined up here in that paragraph and put it back. So after the Clipboard contents metacharacter, I'll go to the Special characters menu to Found and choose Found Text 1, the first Subexpression in here, the first bit of Found Text.
I'm asking for that back and it's going to be put back in, preceded by this anchored Text Frame. Let's try a test, and I'm going to do the first one. So it's found what I've described, any character at the beginning of a paragraph that's using the Country Paragraph style. I am going to click Change and let's see what we get. It's inserted my object above that line and replaced that first character that it's found. Let's click Find Next just to be sure. It's finding what I want. I'll click Change and it's changing what I want.
So I'm confident that I have structured this Find/Change operation to do exactly what I want, consistently, through the document. Just to make sure I don't accidentally repeat inserting those in the two instances where I've already put it in, I'm going to click into the text in the frame on the page. And then I'm going to go back to Find /Change and change my search criteria to To End of Story. And now, I'm going click Change All and InDesign will process this for a moment, and it's processed to 164.
Let's click OK and there you can see them on the page. Let me zoom out and go to page 1 in this document and there's 166 anchored Text Frames placed in a precise location through out a multi-page document using one Find/Change operation. So, now I've got 166 placeholder frames exactly where I want them, ready to start to receive graphics. I'm going close the Find/Change dialog because I've gone as far as I can go in this process using Find/Change and GREP.
But let's just take a look at how you would finish this off, starting with say, the first 10 flags. I'll choose File>Place and from the Links folder, I'll select the first piece of flag art in the list by clicking its name and Shift+Clicking on the last name in the list to select all 10. I'm going to turn-off Show Import options because I want to see 10 successive Show Import options dialogs when I do this. Now I'll click Open and I get InDesign's loaded multi-file place gun and a preview of the first of the 10 images that I'm ready to place.
I can just hover over one of the frames that I placed using GREP earlier, click in that, and it automatically places the art and sizes it to the frame. I'll go ahead and click the next one and the next one and the next one, so on and so on. And this is exactly how I would go about finishing off this project if I was going to take it to conclusion and do all 166 countries. So let's just review what we've done here. We've used GREP Find/Change to identify a specific location within text that uses a specific paragraph style.
We've also used it to insert objects pasted to the Clipboard as anchored objects within that text. After that, that's as far as we could go with Find/Change, but we were able to take advantage of other InDesign features to drop in multiple images throughout a project.
Get unlimited access to all courses for just $25/month.Become a member
120 Video lessons · 64181 Viewers
119 Video lessons · 71636 Viewers
125 Video lessons · 32305 Viewers
103 Video lessons · 31520 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.