![]() ![]() If you’ve got data validation sorted out it’s a simple step to have read only fields in your forms whose values are derived from user entered fields. ![]() If the value entered isn’t valid then a user alert is raised and the focus is returned to the content control Excel Style “Automatic” Calculations If it is valid then the parseCurrency function is used to format the value correctly and write it back to the content control contents. If the control has a tag we’re interested in then the value (Range.Text) is run through the ValidateCurrency function. Content control tags are set on the Developer tab from within Word. In this code we simply check the tag of each content control as users move to the next one. MsgBox "An error has occurred" & vbCrLf & "Module: ThisDocument" & vbCrLf & "Procedure: parseCurrency" & vbCrLf & "Error Number: " & Err.Number & vbCrLf & "Description: " & Err.Description, vbOKOnly Public Function validateCurrency(sValue As String) As Boolean ![]() If Not validateCurrency(CC.Range.Text) ThenĬC.Range.Text = Format(parseCurrency(CC.Range.Text), "$#,#0.00") Private Sub Document_ContentControlOnExit(ByVal CC As contentControl, Cancel As Boolean) For example, here’s a bit of basic validation that ensures the value entered into a field is currency: It’s pretty straightforward if you’re working with content controls if you make use of the ContentControlOnExit event. If you’re doing forms then data validation is critical. I’ve managed to get things working fairly well and thought it worth sharing a bit of code I’ve developed along the way that should help anyone working with Microsoft Word Content Controls and VBA. The only real solution available was to use Word Content Controls and then to protect portions of the document that users shouldn’t be able to edit. Now, Word is not really suited to creating tightly controlled forms, but, in my case it’s all I had to work with and I’ve had to work within the limitations presented to me. These forms had to be developed in good old MS Word. Select an item and use the up or down arrows to change the order, Press - to remove a selected item.ĭrop-down enabled Lets the user open the combo box and make selections.I’ve been developing some “smart” forms a government department in the last few months. Items in drop-down list Shows your current list. Press + or Enter to add an item to the list. If there is default text, user text replaces it.ĭefault Value Choose between Not checked or checked as default.Ĭheckbox size Set a size Exactly or Auto to change size as needed.Ĭheck box enabled Lets the user check or clear the text box.ĭrop-down item Type in strings for the list box items. Text box enabled Lets the user enter text into a field. Text format can set whether text automatically formats to Uppercase, Lowercase, First capital, or Title case. Maximum length sets the length of text that a user can enter. Set Text box enabled to allow the user to enter text into the field. Type Select form Regular text, Number, Date, Current Date, Current Time, or Calculation.ĭefault text sets optional instructional text that's displayed in the text box before the user types in the field. Select Macro to Run on lets you choose a recorded or custom macro to run on Entry or Exit from the field.īookmark Set a unique name or bookmark for each control.Ĭalculate on exit This forces Word to run or refresh any calculations, such as total price when the user exits the field.Īdd Help Text Give hints or instructions for each field.Ĭancel Forgets changes and exits the panel. Select a control and then select Options to set up or make changes. ![]() Options let you set common settings, as well as control specific settings. For more info on sections, see Insert a section break. To do this, choose Select Sections in the Restrict Editing panel. If you want to protect only parts of the document, separate the document into sections and only protect the sections you want. Open the form that you want to lock or protect.Īfter selecting restrictions, select Yes, Start Enforcing Protection. If you want to limit how much others can edit or format a form, use the Restrict Editing command: Select the content control that you want to change. For example, the Date Picker control offers options for the format you want to use to display the date. Set or change properties for content controlsĮach content control has properties that you can set or change. Select the Legacy Form control or Active X Control that you want to include. Go to Developer > Legacy Forms drop-down. Legacy form controls are for compatibility with older versions of Word and consist of legacy form and Active X controls.Ĭlick or tap where you want to insert a legacy control. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |