> For the complete documentation index, see [llms.txt](https://docs.powerpointgeneratorapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.powerpointgeneratorapi.com/examples/shape/get-shape-by-id.md).

# Get shape by ID

PowerPoint's UI does not display shape IDs. You must inspect the underlying Open XML.

#### Method 1 - Unzip the file

A `.pptx` is a ZIP archive.

1. Copy the file and rename the extension from `.pptx` to `.zip`.
2. Extract it.
3. Open `ppt/slides/slide1.xml` (numbering matches slide order) in a text editor.
4. Locate the shape's `<p:nvSpPr>` block. The ID is the `id` attribute on `<p:cNvPr>`:

```xml
<p:spTree>
  <p:nvGrpSpPr>
    <p:cNvPr id="2" name="Textbox 1"/>
  </p:nvGrpSpPr>
  <p:sp>
    <p:nvSpPr>
      <p:cNvPr id="3" name="Chart 1"/>
    </p:nvSpPr>
  </p:sp>
</p:spTree>
```

This slide contains 2 shapes, with IDs `2` and `3`. The `name` attribute is the Selection Pane name, which is your bridge between the visual editor and the XML.

{% hint style="info" %}
**Tip:** In PowerPoint, open **Home → Arrange → Selection Pane** and rename each target shape to something unique (e.g. `chart_q3_revenue`). Then search the XML for that name to find its ID.
{% endhint %}

#### Method 2 - python-pptx

```python
from pptx import Presentation

prs = Presentation("deck.pptx")
for i, slide in enumerate(prs.slides, start=1):
    for shape in slide.shapes:
        print(f"slide {i} | id={shape.shape_id} | name={shape.name}")
```

#### Method 3 - VBA

```vba
Sub ListShapeIds()
    Dim sld As Slide, shp As Shape
    For Each sld In ActivePresentation.Slides
        For Each shp In sld.Shapes
            Debug.Print sld.SlideIndex, shp.Id, shp.Name
        Next
    Next
End Sub
```

Run from the VBA editor (`Alt+F11`) and read output in the Immediate Window (`Ctrl+G`).

#### Notes

* Shape IDs are unique **per slide**, not per presentation. Always pair a shape ID with its slide index.
* IDs are stable across saves and edits, but a copy-pasted shape receives a new ID.
* Shapes inside a group have their own IDs; the group itself also has one.
* Placeholders from the layout carry IDs like any other shape.

Reference: [shapes](/json-template-syntax/shapes.md)

Download: [input.zip](https://drive.google.com/uc?export=download\&id=1lg3VvGtF3lq_4lGIiBd79l23zSRmdsni) | [output.pptx](https://drive.google.com/uc?export=download\&id=1Uy6jmd5cnWqs2OZrVFdO4uqrp7YXswDo)

{% columns %}
{% column width="41.66666666666667%" %}

<figure><img src="/files/w6YFfR4uzgk72aWoNIh9" alt=""><figcaption></figcaption></figure>

***

<figure><img src="/files/ir1D9xNiSui3mpHRkp2E" alt=""><figcaption></figcaption></figure>
{% endcolumn %}

{% column width="58.33333333333333%" %}
{% code lineNumbers="true" %}

```json
{
    "presentation": {
        "template": "template.pptx",
        "slides": [
            {
                "slide_index": 0,
                "shapes": [
                    {
                        "shape_id": 6,
                        "data": [
                            ["Q1", "Q2", "Q3", "Q4"],
                            ["Product A", "Product B", "Product C", "Product D"],
                            [45, 32, 20, 18],
                            [55, 40, 30, 22],
                            [60, 48, 36, 28],
                            [72, 55, 42, 35]
                        ]
                    }
                ]
            }
        ]
    }
}

```

{% endcode %}
{% endcolumn %}
{% endcolumns %}
