Identify the ID / Number of each Text Box Shape

1

I started using VBA for powerpoint and needed to start referenceing my code to each Shape within the presentation. But I do not know the name of each Shape to reference. How do I know that a text box is shape (1), shape (2), or shape (40).

Detail, I'm working with powerpoints ready, that is, I do not know the order in which each shape was created.

Is there somewhere I can check the number of each Shape?

    
asked by anonymous 30.05.2018 / 22:58

1 answer

0

Text Boxes

If you want to get only text boxes like the image below:

The.HasTextFramepropertycanbeusedinaloopinallpresentationsandshapes.

Code

DimsldAsSlideDimshpAsShapeForEachsldInActivePresentation.SlidesForEachshpInsld.ShapesIfshp.HasTextFrameThenDebug.Print"Texto: " & shp.TextFrame2.TextRange & " " _
                ; "ID: " & shp.Id & " " _
                ; "Nome: " & shp.Name
            End If

Next shp
Next sld

All Shapes

For all Presentation Shapes, you can get the Type, ID, and Name.

Code

Dim sld As Slide
Dim shp As Shape
Dim sr As Series
Dim txt As Chart

    For Each sld In ActivePresentation.Slides
        For Each shp In sld.Shapes
                Debug.Print "Tipo: " & shp.Type & " " _
                ; "ID: " & shp.Id & " " _
                ; "Nome: " & shp.Name
Next shp
Next sld

List of Types

+----------------------+-------+----------------------------------+
|         Nome         | Valor |            Descrição             |
+----------------------+-------+----------------------------------+
| msoAutoShape         |     1 | AutoForma.                       |
| msoCallout           |     2 | Texto Explicativo.               |
| msoCanvas            |    20 | Tela.                            |
| msoChart             |     3 | Gráfico.                         |
| msoComment           |     4 | Comentário.                      |
| msoContentApp        |    27 | Suplemento de conteúdo do Office |
| msoDiagram           |    21 | Diagrama.                        |
| msoEmbeddedOLEObject |     7 | Objeto OLE incorporado.          |
| msoFormControl       |     8 | Controle de formulário.          |
| msoFreeform          |     5 | Forma Livre.                     |
| msoGraphic           |    28 | Elemento gráfico                 |
| msoGroup             |     6 | Grupo.                           |
| msoIgxGraphic        |    24 | Gráfico SmartArt                 |
| msoInk               |    22 | Tinta                            |
| msoInkComment        |    23 | Comentário à tinta               |
| msoLine              |     9 | Linha                            |
| msoLinkedGraphic     |    29 | Gráfico vinculado                |
| msoLinkedOLEObject   |    10 | Objeto OLE vinculado             |
| msoLinkedPicture     |    11 | Imagem vinculada                 |
| msoMedia             |    16 | Mídia                            |
| msoOLEControlObject  |    12 | Objeto de controle OLE           |
| msoPicture           |    13 | Imagem                           |
| msoPlaceholder       |    14 | Espaço reservado                 |
| msoScriptAnchor      |    18 | Âncora de script                 |
| msoShapeTypeMixed    |    -2 | Tipo de forma misto              |
| msoTable             |    19 | Tabela                           |
| msoTextBox           |    17 | Caixa de texto                   |
| msoTextEffect        |    15 | Efeito de texto                  |
| msoWebVideo          |    26 | Vídeo da Web                     |
+----------------------+-------+----------------------------------+
  

Obs. 1: See The Shapes documentation for more information

     

Obs. 2: To see what is printed with the command Debug.Print , you must enable the Immediate Scan window.

    
12.06.2018 / 13:49