Hack 75 Include an Interactive Calendar in Your Forms![]() ![]() easy-to-use calendar for choosing dates from within a form or other document.If you use Word's Forms feature, many of your forms probably include DATE fields. Word provides some dates for you, such as today's date and the date a document was created. However, if you want the form's user to fill in a date, you can prompt the user to select the date from an interactive calendar, such as the one shown in Figure 8-5. Figure 8-5. An interactive calendar placed in a form![]() control included with Office. With some simple steps in the Visual Basic Editor, along with a few lines of code, you can easily add this calendar to any form. With your form template open, select Tools Insert the Toolbox visible. Right-click the Toolbox and choose Additional Controls to display the dialog shown in Figure 8-6. Scroll down and check the "Calendar Control 11.0" box (the version number may be slightly different on your system). Figure 8-6. Activating the Calendar control![]() Click it and draw a new calendar on your blank UserForm, as shown in Figure 8-7. In the Properties window, change the UserForm's caption to "Calendar." Figure 8-7. Add the Calendar control to a UserForm in the Visual Basic Editor![]() Private Sub UserForm_Activate( )Now, in a code module in your template (if none exists, select Insert Sub ChooseDate( )Then select File which you want the calendar to appear and choose Properties to display the dialog shown in Figure 8-8. Select the ChooseDate macro to run when the field is entered. Figure 8-8. Select the macro to display the Calendar control![]() button on its titlebar. 8.7.1 Hacking the HackThough it's ideally suited for fill-in forms, you may find the Calendar control useful in other documents too. To insert the Calendar control into any document, use a MACROBUTTON field, as shown in Figure 8-9. These fields assume you're using the same ChooseDate macro described above for activating the Calendar control. The field code is shown in the first field, and the field result is shown in the second field. Figure 8-9. The first field shows the field code; the second shows the field result![]() |