Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
word and forms: updating a table by adding more rows
Hello,
I have an ordering form that I created a while ago which I would like to modify. In the form I have a table with columns for 'item description', 'size', 'cost per unit', and 'quantity'. When the form is protected users can fill in the descriptions and values. When 'quantity' and 'cost per unit' are filled in, a cell at the end of the row automatically fills in with the subtotal. This table is fixed at 10 rows, and cell in another table automatically sums all the subtotals together, adds in a predetermined amount of shipping and handling charges and displays the result. The question I have is: Is it possible to have the form open up with two rows in the table (for filling in 'item description', 'size', 'cost per unit', and 'quantity'), and when the user fills in the second row a third row appears (and if they fill in the third row, a fourth row appears, etc.)? Could this happen and the total (in the other table) be calculated as it is now? Thanks. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
word and forms: updating a table by adding more rows
' 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.Table s(1).Rows.Count, _ ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro = "addrow" ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(1).Rows.Count, 1).Range.FormFields(1).Select ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End Sub In addition, you will probably need to incorporate the code from the article "How to assign a Name to a FormField that doesn't already have a Name, using VBA" at: http://www.word.mvps.org/FAQs/Macros...ameToFmFld.htm so that you can name the new formfields and thus be able to reference them in assigning a formula to the last formfield in each row so that it will display the total for that row and also in a formula that calculated the total of all of the rows. -- 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 "oj" wrote in message ... Hello, I have an ordering form that I created a while ago which I would like to modify. In the form I have a table with columns for 'item description', 'size', 'cost per unit', and 'quantity'. When the form is protected users can fill in the descriptions and values. When 'quantity' and 'cost per unit' are filled in, a cell at the end of the row automatically fills in with the subtotal. This table is fixed at 10 rows, and cell in another table automatically sums all the subtotals together, adds in a predetermined amount of shipping and handling charges and displays the result. The question I have is: Is it possible to have the form open up with two rows in the table (for filling in 'item description', 'size', 'cost per unit', and 'quantity'), and when the user fills in the second row a third row appears (and if they fill in the third row, a fourth row appears, etc.)? Could this happen and the total (in the other table) be calculated as it is now? Thanks. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stop adding rows to end of table | Tables | |||
Adding rows to a table | Tables | |||
Adding rows to a table | New Users | |||
Why do rows in a table stack when adding a new row? | Tables | |||
Adding multiple rows to a table in Word? | Microsoft Word Help |