Forum Discussion

Deon_Olivier's avatar
Deon_Olivier
Copper Contributor
Oct 03, 2023

Rename a text box in Word

Hi all,

New to this forum and hope to make use of your expertise as I am new at Word automation.

 

I have a document (Word 365 / 2019) with 3 textboxes that I have inserted using "Insert -> Shapes".

I want to rename these 3 textboxes to my own names.so that I may reference them in my code in Access.

I am unable to locate where I may change the names of the Textboxes. I tried the Developer tab and in Design mode, use the property function, but I still cannot locate wher I can rename the Textboxes.

 

Any help will be appreciated.

 

Thanks

  • Deon_Olivier 

     

    You can rename objects (text boxes, shapes, images) in the Selection pane, as other contributors have pointed out in this thread. 

     

    I think the Developer options you mention apply to UserForms (= custom dialog boxes) and the Visual Basic Editor, which is the programming interface in Word. 

    • Deon_Olivier's avatar
      Deon_Olivier
      Copper Contributor
      Hi all,
      After all the comments received, I could sort the issue and rename the textboxes using the selection pane.
      The code now runs smoothly, and all issues has been resolved.

      Thanks guys!! Much appreciated.
  • LeonPavesic's avatar
    LeonPavesic
    Silver Contributor

    Hi Deon_Olivier,

    o rename textboxes in Word 365 / 2019, follow these steps:

    1. Select the textbox you want to rename.
    2. Go to the Developer tab.
    3. Click the Selection Pane button in the Arrange group.
    4. **In the Selection Pane, right-click the textbox and select Rename.
    5. **Enter a new name for the textbox and click OK.

    Note: If the Developer tab is not visible, right-click on the ribbon and select Customize the Ribbon. Then, check the box next to Developer and click OK.

    Example:

    To rename a textbox named "TextBox1" to "MyTextBox", you would follow these steps:

    1. Select the textbox named "TextBox1".
    2. Go to the Developer tab.
    3. Click the Selection Pane button in the Arrange group.
    4. In the Selection Pane, right-click the textbox named "TextBox1" and select Rename.
    5. Enter "MyTextBox" in the Name field and click OK.

    Once you have renamed the textbox, you can reference it in your Access code using the following syntax:

    ActiveDocument.Shapes("MyTextBox").TextFrame.TextRange

    For example, to get the text in the textbox named "MyTextBox", you would use the following code:

    Dim myTextBox As TextFrame
    Set myTextBox = ActiveDocument.Shapes("MyTextBox").TextFrame
    Dim myText As String
    myText = myTextBox.TextRange.Text


    Please click Mark as Best Response & Like if my post helped you to solve your issue.
    This will help others to find the correct solution easily. It also closes the item.


    If the post was useful in other ways, please consider giving it Like.


    Kindest regards,


    Leon Pavesic
    (LinkedIn)

  • Charles_Kenyon's avatar
    Charles_Kenyon
    Bronze Contributor

    Deon_Olivier 

    While my Shape Format Tab has an Arrange Group, my Developer Tab does not.

     

    .

     

     

    I have virtually no experience with Access but a lot with Word and this is posted in the Word forum.

     

    If using the Windows version, I would select and save the textboxes in the Textbox or Custom Textbox Building Blocks Gallery assigning them names and categories as desired. They would then be accessed using Insert > Text Box rather than Insert > Shape in Word, itself.

     

    Here is my writing on saving as a Building Block and the vba code used to insert Building Blocks.

    Saving AutoText and Other Building Blocks

    Using VBA to Insert an AutoText Entry or other Building Block

     

    If you need more information on Building Blocks I would be happy to provide it.

     

     

Share

Resources