Form Automation Help

K

Katherine R

I have created a set of five Word forms that are used at my work when
conducting inspections. All five forms are included in one document and
numbered page 1 of 5, 2 of 5, etc. The forms have text form fields and
drop-down form fields so the document is locked, of course. Each section is
created using a table. My question involves form 1 (page 1). The top
section of form 1 has place for the inspectors name, date and time of
inspection, location of inspection, etc. This is followed by more sections -
one for driver information, one for vehicle information, and one for company
information. The Vehicle Information section provides a space for vehicle
license number, state of issue, vehicle make, VIN Number and so on. It is
possible that an Inspection Location as listed in the top section of form 1
could have more than one vehicle. Is there a way to automate this in Word so
that the user can add multiple Vehicle Information section if the locations
has multiple vehicles?

I hope I've explained this clearly.
 
D

Doug Robbins - Word MVP

You could have the following macro run on exit from the last of the
formfields that may need to be duplicated. You will probably want to modify
it however by first displaying a yes/no message box so that it asks the user
if they need to add additional vehicles and only adds the extra fields if
they answer yes

' Macro created 02/02/03 by Doug Robbins

' To add a new row to a table containing formfields in every column

' automatically on exit from the last cell in the present last row of the
table

Dim rownum As Integer, i As Integer

ActiveDocument.Unprotect

ActiveDocument.Tables(1).Rows.Add

rownum = ActiveDocument.Tables(1).Rows.Count

For i = 1 To ActiveDocument.Tables(1).Columns.Count

ActiveDocument.FormFields.Add
Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range,
Type:=wdFieldFormTextInput

Next i

ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
1).Range.FormFields(1).Select

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top