P
Peter
I'm working on a forty page Word 2000 form used to collect
information from faculty about their activities. The form
is emailed as an attachment, filled out on an individual's
PC, and printed. The data is collected in about 150 two-
column tables that have various numbers of rows from four
to sixteen. In the first row of every table, the first
column contains a numeric bookmark that is the sum of the
numeric booksmarks in the first column of the two-to-
sixteen rows following. This sum is the result of
a 'Calculation' in the Text Form Field Option box. The
second column in the first row of every table simply
contains text describing a particular faculty activity and
the points it can be awarded. The second row is always
blank to enhance readability.
In rows three through sixteen, the first column contains a
Number bookmark where the user enters a number that
assigns a point value for the text they have entered in
the Regular Text bookmark in the second column. The Number
bookmark is from the 'Number' option in the Text Form
Field Option box, and 'Calculate on exit' is checked.
The 'Regular Text' option with a length of 750 characters
takes care of the text entries in the second column.
The form described above works well. I have described it
in some detail as requested it the 'Tips for Posting to
Newsgroups'.
What I am trying to work out, and my reason for writing
this group, is as follows:
1. Since faculty will not have any activities to report in
many of the tables, we would like to delete all tables
that have a zero in the Calculated (sum) bookmark that
always appears in the first column of the first row, and
also delete the blank line that follows each table on the
page, before the form is printed.
2. Place a button on the form at the end of the tables
that the user can click to initiate the deletion process
prior to printing the form. This deletion of empty tables
will ultimately save thousands of pages of paper, and
result in much cleaner and more readable reports.
3. Sum all of the Calculated bookmarks and place the grand
total in a field at the end of the document.
I have looked through nearly all the word.vba.beginners,
word.tables, and word.vba.general subject lines, as well
as the text of many of the associated items, but so far
haven't found any topics that involve deleting tables
based on the contents of a bookmark, though I could easily
be overlooking something since I'm new to vba.
Based on my limited experience with dBase IV and COBOL, I
think the pseudo code for what I'm trying to do would look
something like this:
1. See if the 'Delete Blank Tables' button has been clicked
2. Unprotect the form (my assumption since must unprotect
to modify current version)
3. Increment a loop until first table is found or EOF
(there's a lot of other text in the document not in tables)
4. When a table is found, see if the first (the calculated
sum) bookmark = 0. (There are as many as 16 bookmarks in a
table, but they will all be 0 if the calculated (total)
bookmark = zero)
5. If first bookmark = 0, delete the table and the line
directly following the table; If first bookmark NOT = 0,
add its contents to the running total.
6. Look for the next table
7. When reach EOF, place the running total in the total
field.
8. Exit the deletion routine.
9. Protect the form again
10. Return to the form
I would certainly appreciate any assistance anyone can
give me, including directing me to material that would
help me understand how vba moves through a word document,
identifies various objects and performs operations on what
it encounters. I've purchased three vba books I've seen
mentioned on this list, but none of them have examples
that are of much help to a beginner.
Thank you,
Peter
information from faculty about their activities. The form
is emailed as an attachment, filled out on an individual's
PC, and printed. The data is collected in about 150 two-
column tables that have various numbers of rows from four
to sixteen. In the first row of every table, the first
column contains a numeric bookmark that is the sum of the
numeric booksmarks in the first column of the two-to-
sixteen rows following. This sum is the result of
a 'Calculation' in the Text Form Field Option box. The
second column in the first row of every table simply
contains text describing a particular faculty activity and
the points it can be awarded. The second row is always
blank to enhance readability.
In rows three through sixteen, the first column contains a
Number bookmark where the user enters a number that
assigns a point value for the text they have entered in
the Regular Text bookmark in the second column. The Number
bookmark is from the 'Number' option in the Text Form
Field Option box, and 'Calculate on exit' is checked.
The 'Regular Text' option with a length of 750 characters
takes care of the text entries in the second column.
The form described above works well. I have described it
in some detail as requested it the 'Tips for Posting to
Newsgroups'.
What I am trying to work out, and my reason for writing
this group, is as follows:
1. Since faculty will not have any activities to report in
many of the tables, we would like to delete all tables
that have a zero in the Calculated (sum) bookmark that
always appears in the first column of the first row, and
also delete the blank line that follows each table on the
page, before the form is printed.
2. Place a button on the form at the end of the tables
that the user can click to initiate the deletion process
prior to printing the form. This deletion of empty tables
will ultimately save thousands of pages of paper, and
result in much cleaner and more readable reports.
3. Sum all of the Calculated bookmarks and place the grand
total in a field at the end of the document.
I have looked through nearly all the word.vba.beginners,
word.tables, and word.vba.general subject lines, as well
as the text of many of the associated items, but so far
haven't found any topics that involve deleting tables
based on the contents of a bookmark, though I could easily
be overlooking something since I'm new to vba.
Based on my limited experience with dBase IV and COBOL, I
think the pseudo code for what I'm trying to do would look
something like this:
1. See if the 'Delete Blank Tables' button has been clicked
2. Unprotect the form (my assumption since must unprotect
to modify current version)
3. Increment a loop until first table is found or EOF
(there's a lot of other text in the document not in tables)
4. When a table is found, see if the first (the calculated
sum) bookmark = 0. (There are as many as 16 bookmarks in a
table, but they will all be 0 if the calculated (total)
bookmark = zero)
5. If first bookmark = 0, delete the table and the line
directly following the table; If first bookmark NOT = 0,
add its contents to the running total.
6. Look for the next table
7. When reach EOF, place the running total in the total
field.
8. Exit the deletion routine.
9. Protect the form again
10. Return to the form
I would certainly appreciate any assistance anyone can
give me, including directing me to material that would
help me understand how vba moves through a word document,
identifies various objects and performs operations on what
it encounters. I've purchased three vba books I've seen
mentioned on this list, but none of them have examples
that are of much help to a beginner.
Thank you,
Peter