Tables and Formulas in Forms

B

Bert0529

Hello All,

I am creating a commercial invoice form and in that form I have a table with
the following fields:

Item Number, Quantity, Unit, Description, Unit Price, Total Price

The way I'd like the form to work is that the user can enter information
under the various headings for as many Items as there are using one row for
each item. In other words a row would be added when needed for each new line
item and the calculations would be performed automatically (including the
totalling the the Total Price column). Any suggestions for how to accomplish
this?

In my tinkering I once came across a means of entering data into the fields
of the table by a means that used a yellow-ish shaded text area. I cannot
seem to refind that function. If this sounds familiar please tell me the name
of this feature.

Thank you,

Bert
 
D

Doug Robbins - Word MVP

You could use a modification of the following code to accomplish what you
are after. It will however take a bit more code than is provided here:

' 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