Results 1 to 4 of 4
  1. #1
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    70

    Rename textbox in Word

    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 (Word Automation).
    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 where I can rename the Textboxes.

    Any help will be appreciated.



    Thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,945
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    70
    Thanks Welshgasman - issue resolved.
    Now I have another issue. I am unable to reference the shapes in Access VBA. I get an error message "Method or data member not found":

    Code:
            For Each shp In .ActiveDocument.Shapes            If .ActiveDocument.Trim(Left(shp.TextFrame.TextRange.Text, 17)) = "Student Name here" Then
                     shp.TextFrame.TextRange.Text = Rst1!FirstName & " " & Rst1!Surname
                End If
            Next
    The debug window shows the member not found, is ".TextRange.Text....".
    Running the above code in the WORD document, it runs 100%, but as soon as I run it in VBA, I get the error message.

    Any idea why?

    Thanks

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,945
    You would need to prefix with the word document object or the word app object, likely word app object if you are using activedocument.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Rename word document during copy/paste
    By Homegrownandy in forum Programming
    Replies: 3
    Last Post: 07-17-2018, 08:15 AM
  2. Replies: 2
    Last Post: 03-24-2016, 03:38 AM
  3. Populate Word template with data from textbox
    By Kevo in forum Database Design
    Replies: 2
    Last Post: 10-18-2014, 07:57 AM
  4. Replies: 8
    Last Post: 04-14-2013, 01:33 PM
  5. Call word object and import word fields
    By silverspr in forum Programming
    Replies: 3
    Last Post: 12-10-2012, 11:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums