forms that create 2nd page only if needed

B

Butch Cassidy

I have a 2 or 3 page form. The top 1/3 of the first page is demographic form
fields. Then 2nd third is a free form text field that should continue on the
top of the second page if there is excess wordage and continue onto a third
page if there is even more words. The bottom 1/3 of the first page consists
of more smaller fields such as drop down fields and check boxes. My question
is how do I make the words in the large textbox field continue onto the
second page automatically? None of the other form files, either prior to or
after the text field can move position. In other words all form field
positions must start at fixed positions. Only the one large text field would
spill over to the 2nd page if and only if there were excess words that
necessitated the additional space. If, however, everything fit on the first
page then no second page would be generated.
 
C

Cindy M -WordMVP-

Hi Butch,

Word has no functionality that will allow this, so you're going to need to get
"tricky" with a macro. I suggest putting this text field into a one-row,
one-column table with an exact row height. Count how many rows of text will
fit (say, 20). Then code like the following can check this:

Sub NrLinesInField()
Dim i As Long
Dim x As Long
Dim rng As Word.Range

ActiveDocument.FormFields(1).Select
Selection.Collapse wdCollapseStart
i = i + 1
Do
x = Selection.MoveDown(wdLine, 1, False)
If x > 0 Then i = i + 1
If i = 21 Then
Set rng = Selection.Range
End If
Loop While x > 0
If i > 20 Then
MsgBox "Too long"
rng.End = ActiveDocument.FormFields(1).Range.End - 1
rng.Cut
Set NewDoc = Documents.Add
NewDoc.Range.Paste
End If
End Sub

Once you have this working, you can substitute unprotecting the document,
generating a new page, pasting in the extra text, reprotecting in the code for
the lines that paste into a new document.

Of course, no user will want to be *typing* where he can't see. So you could
have a button the user could click that would generate the new page and put
the user there.

Another possibility would be to capture this in a UserForm.
I have a 2 or 3 page form. The top 1/3 of the first page is demographic form
fields. Then 2nd third is a free form text field that should continue on the
top of the second page if there is excess wordage and continue onto a third
page if there is even more words. The bottom 1/3 of the first page consists
of more smaller fields such as drop down fields and check boxes. My question
is how do I make the words in the large textbox field continue onto the
second page automatically? None of the other form files, either prior to or
after the text field can move position. In other words all form field
positions must start at fixed positions. Only the one large text field would
spill over to the 2nd page if and only if there were excess words that
necessitated the additional space. If, however, everything fit on the first
page then no second page would be generated.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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