Vernier Luxury Suites: Creating a Form Joyce Wu is preparing the design for an online reservation
system. She will be doing the preliminary design of the
controls in Word. Assume the role of Joyce and perform the
steps that she identifies. - Open the "wd12xtra01.doc" Word file and save it as
"Reservation Form" to your personal storage location.
- Display the Forms toolbar.
- Place the insertion point in the table cell to the right
of the "Name" label and insert a text form field.
- Place text form fields in the table cells to the right of
the labels "Arrival" and "Departure".
- Insert a drop down form field in the table cell to the
right of the "Bed" label. Include the following options:
- In the dialog box, click the Add Help Text command
button. Then select the
Status Bar
tab.
- Select the
Type your own
option button and then type the following in the text box
below:
Choose a bed type from the list provided - Close the displayed dialog boxes, saving your
instructions, and return to the document.
- Insert check boxes immediately to the left of the labels
"Smoking" and "Non-Smoking".
- Protect the form and save the revised "Reservation Form"
document. The completed form appears in Figure 12.1.
Figure 12.1 Completed form |  (2.0K)
|
- Test your work by tabbing through each form field and
entering data. Then close the document without saving.
Data File: wd12xtra01 (25.0K) TempSol Staffing: Enhancing Macros
TempSol agent Alyssa Karnes has created a few macros for
importing job data in to a Word document. Her friend Dave is
getting pretty good at VBA and decides to enhance the macros to
be more user-friendly. - Download the following files and save them to your
personal storage location:
- Wd12xtra02a.xls
- Wd12xtra02b.xls
- Open the wd12xtra02.doc Word file and save it as "Job
List Generator" in your personal storage location. (
Note: All three files must be in the same folder for the
VBA code to execute correctly.)
- Notice the instructions and try out the macros.
- Open the Visual Basic Editor by pressing Alt key +
F11 key
- Create a new procedure and call it AutoOpen. This will
cause the procedure to run automatically when the document
is open.
CHOOSE: Insert, Procedure TYPE: AutoOpen as the name CLICK: OK button - With the insertion point now in the newly created
procedure, add a variable called "choice".
TYPE: Dim choice As Integer - Get input from the user by adding a message box.
TYPE: choice = InputBox("Enter 1 for part-time and 2
for full-time.") - Add an If
Then statement to launch the correct
function.
TYPE: If choice = 1 Then GetPartTime Else GetFullTime End If The full procedure is shown in figure 12.2.
Figure 12.2 New AutoOpen procedure |  (2.0K)
|
- Save the new code by clicking the save button and close
the VBA Editor.
- Since the instructions are now moot, select and delete
them.
- Save the document and close it.
- Re-open the document to test your new code. Close
without saving.
Data File: wd12xtra02 (36.0K)
Data File: wd12xtra02a (13.0K)
Data File: wd12xtra02b (13.0K) Jan Dice: Debugging a Macro
Jan Dice bills her clients by the hour. She has created an
invoice template that uses macros and forms for easy input.
However, something has gone wrong in her coding and now she
is getting errors. So, she must face the task of debugging.
Assume the role of Jan and perform the steps that she
identifies. - Open the "wd12xtra03.doc" Word file.
- Jan created a feature that automatically saves the
document with a new name. When prompted, enter a new file
name.
- You will get then get the error shown in figure 12.3.
Click on the Debug button.
Figure 12.3 Runtime Error |  (6.0K)
|
- In the VBA Editor window, the highlighted line of code
contains a syntax error.
Change the code: Selection.GoTo What:= wdGoToBookmark, Name:="
referenceNume
r" To Selection.GoTo What:= wdGoToBookmark, Name:="
referenceNumber
" - Save the document over the original wd12xtra03.doc file
and open it back up.
- Follow the prompts. Everything went fine, but the total
is not correct. Close the document.
- Open the "wd12xtra03.doc" Word file, but disable the
macros.
- Correct the equation that creates the total, "total =
totalHour * rate"
(Hint: One of the variable names is misspelled.) - Save the document.
- Open the document and enable macros. The invoice now
works as expected.
Data File: wd12xtra03 (43.0K) |