I have a VBA program in Word that displays a table with six columns (two of which are hidden) and about a hundred rows. Its function, among other things, is to present vocabulary words to students in both French and English, one set in each row. Because of some subroutines, the width of the columns may change from time to time.
I want to let students work with a sub-set of, say, ten or twenty words the table at a time. Currently, I’ve written a sub that lets students select the rows they want to work on. The sub then cuts unwanted rows above and below the selection, pastes them in another throw-away document where I convert the table to text, replace the paragraph marks with a unique symbol so that the whole is one long string. Then I save the string as a Document Variable in the original document. That removes the unwanted rows from the table.
When the student wants to restore the cut words, I get the deleted rows from the Document Variable, restore the paragraph marks, convert the strings to a table, and then go through the table giving it the character formatting it lost when I first converted the table rows into a string. I then have a new table just beneath the original table. I would like it if the table with the deleted rows could then automatically join the original table, but the column widths between the two tables are different. Any routine that deals with columns fails with a message saying that the table columns have varying widths.
My questions: Is there some routine I could write that would ensure that the column widths are the same between the two tables? If so, would that automatically merge the two tables?
Or is there a better way to solve my basic problem? As a kludge, I am currently selecting the rows to hide, changing the point size to a minimal 3 points, designating the rows as hidden, and storing them all at the bottom of the table so that they remain in the table but are unreadable. It looks sloppy. See the picture of the table below, where the “hidden” rows are at the end and extend down further than the picture shows. Steve Jobs would certainly not approve of that kludge unless there were absolutely no other way to solve the problem.
What is the best way to solve this problem? Note: To convert the original table into strings, put the other strings below, then convert the whole back to a table then takes too long as we have to go through hundreds of character formatting changes that right now I do on just the deleted items.
Thanks for any and all help!