Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve the name of a shape

Tags:

ms-word

vba

In Excel we have the "Name Box" in the upper-left side, but I could not find a way to retrieve the name of a shape in Word. How do I do that?

like image 274
ftkg Avatar asked Jul 16 '13 15:07

ftkg


2 Answers

There are two types of shapes in MS Word- InlineShapes and Shapes. It's quite easy to check name of shape object with some VBA code:

  1. select shape
  2. press Alt+F11 to open VBA Editor
  3. in Immediate window execute this code: ? Selection.ShapeRange.Name
  4. as a result you get name of the shape.

InlineShape doesn't have name property therefore you can't check it's name until you promote your InlineShape to Shape type object.

like image 75
Kazimierz Jawor Avatar answered Oct 21 '22 04:10

Kazimierz Jawor


Microsoft Word 2010 onwards

From Microsoft Word 2010 onwards (2010, 2013 and 2016) there is an "Selection Pane" in Microsoft Word. On the selection pane the Microsoft Word InlineShapes as well as the Shapes are listed and named. Clicking on one of the shape names allows you to change them.

You can find the Selection Pane in the menu under

  1. "Home"-tab
  2. "Editing"-group
  3. "Select"-button
  4. "Selection Pane..."

Microsoft Word Selection Pane


Microsoft Word versions before 2010

For older Microsoft Word (2003, 2007) versions use the VBA approach (?Selection.ShapeRange.Name) as Kazimierz Jawor posted as an other answer to this question: https://stackoverflow.com/a/17680650/1306012

  1. Select the shape
  2. Open the VBA editor by pressing Alt+F11
  3. Open the immediate window by pressing Ctrl+G
  4. Type ?Selection.ShapeRange.Name in the immediate window to get the shape name
like image 33
Bruno Bieri Avatar answered Oct 21 '22 06:10

Bruno Bieri