# Looking for a simpler way to add an anchored object to a cell

**URL:** https://forums.creativeclouddeveloper.com/t/looking-for-a-simpler-way-to-add-an-anchored-object-to-a-cell/7490
**Category:** InDesign
**Tags:** javascript
**Created:** [February 5, 2024, 10:47pm UTC](https://forums.creativeclouddeveloper.com/t/looking-for-a-simpler-way-to-add-an-anchored-object-to-a-cell/7490 "2024-02-05T22:47:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![casualMaleXL](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/casualmalexl/32/3457_2.png) [@casualMaleXL](https://forums.creativeclouddeveloper.com/u/casualMaleXL)
#### Post date: [February 5, 2024, 10:47pm UTC](https://forums.creativeclouddeveloper.com/t/looking-for-a-simpler-way-to-add-an-anchored-object-to-a-cell/7490/1 "2024-02-05T22:47:30Z")

</div>

Hang in there, this is a weird one.

I’m creating a plugin that generates bus timetables. This includes generating a “timepoint” for each bus stop, which is a colorful symbol that helps the user find the bus stop on the map. Here’s my current example, the top row of colorful circles are the timepoints:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/2/2faeed8b122e761a7a126b62e29c69473059474e.png)

This is a simplified version of how each timepoint is created in my plugin:

1. Create an oval in the document and style it
2. Create a textframe with a letter, and convert to outlines
3. Align and group the oval and letter
4. **Select and cut** the newly-formed group
5. Select the cell’s first insertion point and **paste** the group

And this works! It works well! But it’s slow and goofy. Here’s what it looks like:

![InDesign_Zl68YoR5Wm](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/2/2291692e28651f0359fa746d9fc840f728e32844.gif)

You can see the timepoint created at the document origin and then pasted in each cell. Each timepoint is an anchored object and acts like a character:

![InDesign_IRLfrPY4PM](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/3/341aaefe2b586a496b9e1f29cc0aa9417931c0e8.gif)

Now the problem is this approach is pretty slow, and I figure there must be a more direct way to set the cell’s contents instead of cutting and pasting. Well how about I just set the `cell.contents` to the group, then?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/0/09f674c0fb55e6aa5d1947acc5fa8cc029621f23.png)

This approach just sets the cell types to graphic cells. Converting them to text cells results in the intended behavior, but the stretched timepoint remains. I’ve also tried converting the cell to a text cell before setting the contents, but same thing.

So this all boils down to: **how can I programmatically insert an anchored object into a text cell?**

---

<div class="post-metadata">

### Author: ![vamitul](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/vamitul/32/3075_2.png) [@vamitul](https://forums.creativeclouddeveloper.com/u/vamitul)
#### Post date: [February 6, 2024, 6:26am UTC](https://forums.creativeclouddeveloper.com/t/looking-for-a-simpler-way-to-add-an-anchored-object-to-a-cell/7490/2 "2024-02-06T06:26:22Z")

</div>

```js
group.anchoredObjectSettings.insertAnchoredObject(cell.insertionPoints.item(0),AnchorPosition.INLINE_POSITION) 

```

---

<div class="post-metadata">

### Author: ![casualMaleXL](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/casualmalexl/32/3457_2.png) [@casualMaleXL](https://forums.creativeclouddeveloper.com/u/casualMaleXL)
#### Post date: [February 6, 2024, 2:42pm UTC](https://forums.creativeclouddeveloper.com/t/looking-for-a-simpler-way-to-add-an-anchored-object-to-a-cell/7490/3 "2024-02-06T14:42:17Z")

</div>

Thank you so much! Exactly what I was looking for.
