Avatar of mvp1985
 asked on

How to select first form field of newly pasted part of document automatically with macro

So I have a great macro that unprotects a document, goes to the end of the document, pastes an autotext, and then reproects the document. However, I need to manually  tab through the form fields in order to get to the newly inserted part. So here my question: How do I get the macro to automatically advance to the first form field of the newly pasted part once I run the macro?

Here is my current macro:

Sub Macro3a()
    Dim aDoc As Document
    Dim strPassword As String
    strPassword = ""
    Set aDoc = ActiveDocument
    If aDoc.ProtectionType <> wdNoProtection Then
        aDoc.Unprotect strPassword
    End If
    Application.Templates(aDoc.AttachedTemplate.FullName). _
        BuildingBlockEntries("Schätzung 1").Insert Where:=aDoc.Bookmarks("\EndOfDoc").Range
    aDoc.Protect Type:=wdAllowOnlyFormFields, Password:=strPassword
 End Sub
Microsoft Word

Avatar of undefined
Last Comment

8/22/2022 - Mon

try this


pls try



None of these work, since the suggested sollutions selects the very first form field of the document on the first page. However, I need the form field selected that is the first one that I just pasted.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck

Ok, you can add a bookmark before doing the insertion and then move back to that bookmark

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Are you sure that you understand the normal use of form fields?

The idea is that you design the document manually,  placing form fields in places where the text might  be changed by the user. By default , each form field is bookmarked (Text1, Text2, etc). The bookmark name becomes the form field name.You then protect the document for forms.

The user can then only change the text in the form fields. It can be done programatically without removing the protection:
ActiveDocument.FormFields("Text1").Result = "some new text"

Open in new window