top of page
Search

How To Create Forms In Word With ActiveX Controls: Easy And Effective Methods



There are several types of forms that you can create in Excel: data forms, worksheets that contain Form and ActiveX controls, and VBA UserForms. You can use each type of form by itself, or you can combine them in different ways to create a solution that's right for you.


ActiveX controls can be used on worksheet forms, with or without the use of VBA code, and on VBA UserForms. In general, use ActiveX controls when you need more flexible design requirements than those provided by Form controls. ActiveX controls have extensive properties that you can use to customize their appearance, behavior, fonts, and other characteristics.




How To Create Word Forms With ActiveX Controls (How To Create Forms In Word



After adding forms and ActiveX to a worksheet form, you usually want to fine-tune and rearrange the controls in a variety of ways to create a well-designed, user friendly form. Common tasks include the following:


You can add controls to your documents to create interactive documents, such as online forms. For general information about adding and working with controls, see Using ActiveX controls on a document and Creating a custom dialog box.


The ability to create customized, interactive forms to collect data is a powerful, but often underutilized feature of Word. In this blog, we will discuss how to create electronic forms using form controls such as text content, drop-down list, and check box. In addition, you will learn how to protect the form and collect data.


2) To make it easier to move all the form controls that were affected by the strange behaviour at once, I selected them and with right click, I had chosen to group them. Doing this, Excel, automatically creates a name for the group of items. In this case the name was "Group 22".


After completing this lesson, you will be able to: Know what the controls on theForms Toolbar (or Developer Tab LegacyForms dropdown) are for.Create an online form to mimic a paper form.Create an online form to fill in a paper form and learn why you probably don't want to attempt this.Create an online form to replace a paper form.Create an online form to prepare a draft legal document.Give the online form user help and on-screen hints.Use form fields that restrict data entry.Protect a forms document from modification.Protect only part of a forms document from modification.Unlock and re-lock a forms document without resetting forms fields.Spell Check a Protected Form.Add "Radio" buttons to a Form.Put buttons on your form for your user that don't print out.Use MacroButton fields in protected portions of your forms (to mimic hyperlinks, among other things) Additional Written (and Web) Resources Word 97 for Law Firms by Payne Consulting Group. (also at Amazon.com UK) Word 2000 for Law Firms by Payne Consulting Group. (also at Amazon.com UK) Word X (2002) for Law Firms by Payne Consulting Group. (also at Amazon.com UK) Please Fill Out This Form - series of articles by Dian D. Chapman, MVP (Dian was formerly known as Dian D. Chesney) - This series is one of the best places to start learning about forms - and a place to return for a refresher when something has you stumped! (Note, this site has been down for more than a year. These links are to archival versions.)Please Fill Out This Form 1 - Creating a FormPlease Fill Out This Form 2 - Automating the FormPlease Fill Out This Form 3 - how to create a form that uses message boxes to inform users and input boxes to request specific informationPlease Fill Out This Form 4 - Custom dialog boxes (userforms) to assist with filling in / using a form - beyond the message and input boxesPlease Fill Out This Form 5 - Linking to a DataBase Creating Forms Using Content Controls by Greg Maxey, MVP Creating Forms in Word 2003 by Paul Edstein, MVP (macropod) Creating Forms in Word Using Content Controls by Kevin Stratvert (video) Creating Automated Forms Using VBA by Greg B. Chapman, MVP Lock Up Your Word Document - Office Watch on Restricting Editing (Word 2003 and later but especially Ribbon versions of Word) Using Word 2010 Checkbox Controls to be mutually exclusive (radio button action) How to best create fill-in-the-blank lines on a form, Suzanne S. Barnhill, MVP and David Rado, MVP Forms FAQ by Cindy Meister, MVP How to Extract Data from Forms and Content Controls by Graham Mayor, MVP - also can be used to convert legacy forms to content controls! How to enable the spell-checker in a protected document, Dave Rado How to hide a "Print" command button on a Form so that it doesn't print by Ibby Mapped Content Controls and Document Properties - Repeating data within a Word Document using these features by Charles Kenyon Repeating Data - entering once and having it show up elsewhere! by Greg Maxey, MVP Bookmarks and Fields Sampler by Joseph Freedman with additions from Charles Kenyon How to change the action of the Enter key in forms (alsoQ187985) How to validate the contents of a Word Form field by Dave Rado, MVP How to set the "tab order" of a Word Form by Dave Rado, MVP and Mark Tangard The best way to select a form field using VBA by Mark Tangard Enable a user to change a "Y" to an "N" and back by double-clicking - by Bill Coan, MVP Why Does the Appearance (or layout) of My Document Change When I Open It On a Different Machine? Suzanne S. Barnhill, MVP How to insert the filename and path on the last page of a document, such that it will be updated automatically if the filename or path changes by Bill Coan, MVP. Using a MacroButton Field to Emulate a Hyperlink in a Protected Form by Charles Kenyon Creating Forms with Word 2010 (pdf) Create Forms that Users Complete or Print in Word - Microsoft web site (Word 2007/2010) Conditional Drop-Down Form Fields Word Bookmarks by Cindy Meister How to find the name of the current formfield by Astrid Zeelenberg Microsoft Support - Forms Tab Key behavior in Protected Forms by Geoff Whitfield - making the tab key go to next form field in the unprotected part of a form What to do if you forget the password in a locked form by Graham Mayor, MVP. Quick Parts vs. AutoText - When is one a better choice? by legal office guru Deborah Savadra (video) - this is a good short video demonstrating use of the Building Blocks Gallery Content Control and other Content Controls in a form letter templaate. Word 2010 Forms in Depth - online tutorial on lynda.com by Gina Courter Chapter 44 of Microsoft Word 2010 Bible by Herb Tyson, MVP From Word to ... (Getting Data out of Word, esp. Word Forms) by Cindy Meister (Advanced) Microsoft Knowledge Base Q212328 WD2000: How to Create an Online Form Using Form Fields Q212378 WD2000: How to Control the Tabbing Order in a Form Q211219: How to change the action of the Enter key in forms (alsoQ187985) Q212101 WD2000: Ampersand Is Displayed Incorrectly in Drop-Down List Box Q212080 WD2000: Length of Form Field Expands or Contracts, Affects Alignment Q212356 WD2000: How to Update Fields in a Protected Form Q212540 WD2000: How to Create Mutually Exclusive Check Boxes by Using a Macro (Radio Button Action) Q95133 WD: How to Create a Checked/Blank Check Box Using FILLIN Fields Q160988 WD: How to Create Ordinal (Legal) Dates in Form Fields Q212394 WD2000: AutoCorrect TextDeleted or Partially Visible in Form Field Microsoft Support - Forms Chapter 16 ofMicrosoft Word 2010 In Depth by Faithe Wempen Checkboxes Tutorial - Add-In - Examines different kinds of checkboxes, allows putting active checkboxes in a document / template that is not protected for forms. Create Forms that Users Fill Out or Print on Word for Macintosh - Microsoft - Word 2011 and 2016Note that this article erroneously labels legacy formfields as Content Controls. There is an important difference. Cascading Dropdown Controls by Paul Edstein, MVP Protect Parts of a Word Form by How-to-Geek - good for Content Control forms - better than "filling in forms" protection Protect Part of a Word Form - video - good for filling in forms protection How to Make Word Documents Fillable but Not Editable by Word Geek Add Classic Form Controls to the Ribbon (Word 2007 - 2019) by Greg Maxey, MVP Sample Legacy Forms Public Defender Payment Voucher - Summary cover sheet with five time sheets. Extensive use of tables, cross-references, calculated fields. (download in zip format)Public Defender Transcript Request Form (based on printed form - wild layout of fields using tables, some use of bookmarks, use of exit macros to control tab order. (download in zip format) Macro Package for Form Information Management DataPrompter by Bill Coan, MVP


When a document is protected for forms, or locked, all you can do is work in the formfields that are in the document and in any unprotected sections. You can lock a document for forms using the padlock button on the Forms toolbar or using the Protect Document command under the Tools menu. This second method gives you the option of setting a password to unprotect the form.


In the Ribbon versions of Word you can also Restrict Editing to allow no changes with exceptions. I generally set the exceptions to be for everyone. This requires selecting the areas you want to allow changes and marking them as exceptions. This gives more flexibility and allows use of more Word features. It does not necessarily lock the form down as stringently as filling in forms protection. You should not mix Ribbon-version content controls and legacy formfields in the same document.


This is an extreme challenge to do with any word processing program. Word is no exception. You will keep more of your hair if instead you try to either scan the form and use the scanned image as a background for Word fields or reproduce the form from scratch. Otherwise, what you will want to do is either create a (borderless) table that has spaces for your fields that match where your fields are on the paper or insert frames to hold the fields. In either case, if you change the printer (or even the printer driver) you may need to reform your page.


Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web: For more information about the support options available from Microsoft, please see the following page on the World Wide Web: What follows are the four Visual Basic for Applications macros that you can use together to emulate the Microsoft Word 6.0 for Windows functionality of the ENTER key in new protected form field documents based on a template. For this code to work as written, the template should not be protected. The first macro moves the insertion point to the next form field. The second macro assigns the first macro to the ENTER key. The third macro adds an AutoOpen macro to the ENTER key. The fourth macro removes the assigned macro to the ENTER key, restoring the default functionality of the ENTER key. First Macro: Moves the Insertion Point to the Next Form Field This macro moves the insertion point to the next form field. If the current form field is the last one in the document, it moves the insertion point to the first form field. This macro uses the Bookmarks collection to retrieve the name of the current form field. The name of each form field is also the name of a bookmark inserted for the form field. If you have any other bookmarks in your document, you may have to add more code here to handle potential errors. The macro also assumes that all form fields in the documents allow user input. If this is not the case in your document, you will have to add additional code in your macro. The macro checks whether the current section is protected or unprotected, and then either moves to the next form field (in a protected section) or inserts a paragraph mark (in an unprotected section). This functionality is necessary for documents that contain both sections that are protected for form input and for unprotected sections. Sub EnterKeyMacro() ' Check whether the document is protected for forms ' and whether the protection is active. If ActiveDocument.ProtectionType = wdAllowOnlyFormFields And _ Selection.Sections(1).ProtectedForForms = True Then ' Retrieve the bookmark of the current selection. ' This is equivalent to the name of the form field. myformfield = Selection.Bookmarks(1).Name ' Go to the next form field if the current form field ' is not the last one in the document. If ActiveDocument.FormFields(myformfield).Name _ ActiveDocument.FormFields(ActiveDocument.FormFields.Count) _ .Name Then ActiveDocument.FormFields(myformfield).Next.Select Else ' If the current form field is the last one, ' go to the first form field in the document. ActiveDocument.FormFields(1).Select End If Else ' If the document is not protected for forms, ' insert a tab stop character. Selection.TypeText Chr(13) End If End Sub Second Macro: Assigns the EnterkeyMacro Macro to the ENTER Key This macro attaches the EnterKeyMacro macro to the ENTER key, thereby reprogramming the function of the key when it is used in protected document form fields. When you use this macro in a custom template, name it "AutoNew" (without the quotation marks). This will change the functionality of the ENTER key in all new form documents based on the template. Sub AutoNew() ' Do Not protect the template containing these macros. CustomizationContext = ActiveDocument.AttachedTemplate ' Bind the ENTER key to the EnterKeyMacro. KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _ KeyCategory:=wdKeyCategoryMacro, Command:="EnterKeyMacro" ' Reprotect the document with Forms protection. ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End Sub Third Macro: Adds an AutoOpen Macro to the ENTER Key Add an AutoOpen macro with the following code. This ensures that the key functionality will continue when you open a document based on the form template in the future. Sub AutoOpen() ' This macro will reassign the ENTER key when you open an existing ' Word form fields document. CustomizationContext = ActiveDocument.AttachedTemplate ' Bind the Enter key to the EnterKeyMacro. KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _ KeyCategory:=wdKeyCategoryMacro, Command:="EnterKeyMacro" End Sub NOTE: Running these macros may disable some functions, such as AutoCorrect and AutoText, and may affect other features that depend on the ENTER key for proper operation. You need to run the fourth macro to restore the default functionality of the ENTER key or restart Microsoft Word. Fourth Macro: Removes the Command Assigned to the ENTER Key This macro restores the default functionality of the ENTER key. When you use this macro in a custom template, name it AutoClose. Sub AutoClose() CustomizationContext = ActiveDocument.AttachedTemplate FindKey(KeyCode:=BuildKeyCode(wdKeyReturn)).Disable ' Disables prompt to save template changes. Templates(1).Save End Sub NOTE: The CustomizationContext property sets the location where the keyboard customization is to be saved, in this case the template attached to the active document. For additional information, please see the following article in the Microsoft Knowledge Base: Q173707 OFF97: How to Run Sample Code from Knowledge Base Articles 2ff7e9595c


 
 
 

Recent Posts

See All

Comentários


bottom of page