Append new copy of form to document

W

Walter R.

Using Word 2003, I have created several forms which work fine. I would like to add one feature to them, and I can't seem to find any info on how to do it.

I have a command button which enters the user's data in bookmarked locations in the document. I would like this button to also:

- add a new, blank copy of my form to the end of the current document (current document being the form itself)

-optionally (based on a checkbox) clear the data from the textboxes

-then allow the user to input new data for the next copy of the form

The end result is basically what you would get from a merge, (multiple copies of the form, different data in each form, all back-to-back in the same document) but I need more functions than a merge seems to allow, a more user-friendly userform, and I do not need or want to store the user's data permanently. I also want to avoid the burden of adding an .mdb file for the merge. I would really like to do this with VBA, but if anyone knows how I can use my own userform for a merge, that would solve the issue as well.

Thanks,
Walter
 
D

Doug Robbins - Word MVP

The use of bookmarks makes this a bit of a problem as each one must be
unique. If the document is arranged as a table however so that the
locations in which the data has to be inserted can be identified by using
the cell row and column number, then it would be possible to replicate the
table at the end of the document each time and populate it with the data,
then clear the data from the userform ready for the next set of input.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Walter R. said:
Using Word 2003, I have created several forms which work fine. I would
like to add one feature to them, and I can't seem to find any info on how to
do it.
I have a command button which enters the user's data in bookmarked
locations in the document. I would like this button to also:
- add a new, blank copy of my form to the end of the current document
(current document being the form itself)
-optionally (based on a checkbox) clear the data from the textboxes

-then allow the user to input new data for the next copy of the form

The end result is basically what you would get from a merge, (multiple
copies of the form, different data in each form, all back-to-back in the
same document) but I need more functions than a merge seems to allow, a more
user-friendly userform, and I do not need or want to store the user's data
permanently. I also want to avoid the burden of adding an .mdb file for the
merge. I would really like to do this with VBA, but if anyone knows how I
can use my own userform for a merge, that would solve the issue as well.
 
W

Walter

Thanks, Doug. Before seeing your response, I thought about using Form Fields, but I suppose they would have to be unique or all previous instances of the fields would be updated each time data was entered. As you can tell, I'm rather new to Word programming. With this particular form I'm working on now, I think tables will work nicely. But after going over the Tables FAQs on www.mvps.org/word, the only way I can see to do this with some other forms would be to make a single-column table with each paragraph in a separate cell, then use nested, single-cell tables to replace the bookmarks. Is that what you mean?

Two other ideas:
1- Could this be done by adding repeated copies of the form as subdocuments? Would this limit the userform's reference to the bookmarks in the subdocument, thus keeping it from updating fields preivously populated?
2- Would it be possible to use a VB loop statement to rename bookmarks or fields each time a new instance of the bookmark is added? (Just looking for an opinion here, not free code :)

Thanks, I really appreciate the time everyone puts in to answering questions in these forums.

Walter
 
D

Doug Robbins - Word MVP

No, that is not what I meant when suggesting the use of a table - definitely
not to use nested tables.

Say your form amounts to a series of questions for which answers are to be
provided with the questions in the first column of a two column table and
the answers to go into the second column, to insert the answer to the
question that is in the 3rd row of the last table in the document, you would
use

ActiveDocument.Tables(ActiveDocument.Tables.Count).Cell(3, 2).Range.Text =
txtAnswertoQuestion3

The following code will add a newpage to the document and insert a copy of
the first table in the document on that new page every time that it is run:

Dim myrange As Range
Set myrange = ActiveDocument.Range
myrange.Collapse wdCollapseEnd
myrange.InsertBreak
ActiveDocument.Tables(1).Range.Copy
myrange.Paste


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Walter said:
Thanks, Doug. Before seeing your response, I thought about using Form
Fields, but I suppose they would have to be unique or all previous instances
of the fields would be updated each time data was entered. As you can tell,
I'm rather new to Word programming. With this particular form I'm working
on now, I think tables will work nicely. But after going over the Tables
FAQs on www.mvps.org/word, the only way I can see to do this with some other
forms would be to make a single-column table with each paragraph in a
separate cell, then use nested, single-cell tables to replace the bookmarks.
Is that what you mean?
Two other ideas:
1- Could this be done by adding repeated copies of the form as
subdocuments? Would this limit the userform's reference to the bookmarks in
the subdocument, thus keeping it from updating fields preivously populated?
2- Would it be possible to use a VB loop statement to rename bookmarks or
fields each time a new instance of the bookmark is added? (Just looking for
an opinion here, not free code :)
 

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