Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Copying Form Field Contents.
Written by Allen Wyatt (last updated June 28, 2021)
This tip applies to Word 2007, 2010, 2013, and 2016
Let's say you are developing a form and you need to copy the contents of one legacy form field to another. For instance, the form could have multiple pages and you need the user's name at the top of each page. It would obviously be easiest if the user only needed to enter their name once and then it was automatically filled in elsewhere in the form.
There are two ways you can approach this. The first way involves the fact that any time you insert a form field in a document, the contents of the field are automatically bookmarked. Thus, you can use bookmark reference fields throughout your document to refer to whatever the user entered in the field. The second way involves actually copying information from one field to another.
First, let's look at the solution that uses bookmarks. Every time you enter a form field in a document, it is assigned a name. This name depends on the type of form field you entered. You can discover the name (and change it if desired) by right-clicking on the form field and choosing Properties from the Context menu. This displays the Form Field Options dialog box and in the lower portion of the dialog box is the bookmark name for the field. (It will be a name such as Text1.) You should remember this name for the form field whose contents you want to use elsewhere.
Now position your insertion point wherever you want the contents of the form to appear. For instance, at the point where you want the form user's name to appear a second or third time. Here you should follow these steps:
Understand that even though you can reuse form field content information in this manner, the information is not updated automatically when the user leaves the form field. (Well, it is and it isn't.) You sort of have to trust Word on this, since the contents of fields (the REF field) are not generally updated until you print or look at a print preview for the document. The field can, of course, also be updated by selecting it and pressing F9. Either of these requires manual action on the part of the user, but it is possible to start creating macros that would do it automatically.
The second general method for copying field contents involves literally copying the information from one field to another. This must be done with a macro and does seem like a bit of overkill in light of the bookmark feature already discussed. However, there may be times when you actually need two form fields in your document and you want the second form field to default to whatever the user entered into the first form field. In this case, you must make note of the names assigned to the form fields by Word. For purposes of this discussion, let's assume those names are Text1 and Text2, and that you want to copy the contents of Text1 to Text2 as soon as the user leaves Text1. You can use the following simple macro:
Sub CopyField() Dim Temp as String Temp = ActiveDocument.FormFields("Text1").Result ActiveDocument.FormFields("Text2").Result = Temp End Sub
Now you need to configure your first field so that the macro is executed every time the field is left. You do this by following these steps:
Now protect the document for fields and save your form template. The next time you create a new document from the template the user will be able to fill in the fields. When the Text1 field is exited, the Text2 field is instantly updated with whatever was entered in Text1. Understand that the user can then change whatever is in Text2; the change was simply to set the default. You should also understand that if the user "cycles back" and changes Text1 again and then exits that field, the contents of Text2 are changed regardless of what was there before.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (10392) applies to Microsoft Word 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Word here: Copying Form Field Contents.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Word allows you to create forms and then export the data from those forms into files that can be used by other programs. ...
Discover MoreWord allows you, as part of your document, to create forms. To start using the form, you need to protect the document. If ...
Discover MoreIf you create a form using Word, chances are good that you don't want a user to mess up the layout of the form by ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2017-09-26 15:12:04
Hello,
I tried using this tip and everything worked fine while I used the document on my computer. But then I emailed it to a co-worker, and they tried to fill it out and the macros aren't running. They're using the same version of word I am (2013) and I tried saving as .docx, .dotm, .dotx, and .docm. Nothing is working.
Any ideas on what could be preventing the macros from running when others try to open the document? I made sure it's not opened in a read only mode or anything like that. But I'm out of ideas.
Thank you!
Mandy
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments