View Single Post
 
Old 09-10-2014, 03:23 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

To automate the process, you could use a Selection_Change macro, but that's a lot of work to implement. A simpler approach would be to have another formfield, say a checkbox formfield, in the second cell on the last row that, when clicked, triggers the macro. You do that by selecting the macro from the formfield's 'on entry' property. To use the same macro on multiple tables, you could then simply change:
With .Tables(1)
to:
With Selection.Tables(1)
and, if you want to delete the formfield that triggered the macro as well, insert:
Selection.FormFields(1).Delete
before:
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=StrPwd

PS: I note you're using a formfield to tally the column-2 values. The problem with this approach is that (a) you're using bookmarks that may get deleted when the referenced rows get deleted; (b) there's nothing in your code to cause the tally to update; and (c) calculation formfields taking input from other formfields are dodgy. To resolve (a) and (c), replace the calculation formfield with a formula field, coded as:{=SUM(ABOVE) \# £0.00 }
For (b), check each of the other formfields' 'calculate on exit' property.

Note: The field brace pairs (i.e. '{ }') for the above example are created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote