Appending new pages when filling out form

G

GaryatBeowulfs

I have a one page form that I need some help with. The form is used to track
daily account summaries and has space enough for two accounts. The problem is
there may be more than two accounts for that day. What I want to avoid is
having to open a new instance of the template for each two accounts.

Is there a way to insert new pages with the form layout as needed within the
same document? Like maybe a custom toolbar with an insert page button (how
would you do that?) or something? And while I'm thinking about it, if the
answer is a custom toolbar, can they be document specific? That is, would I
see the toolbar if I was working on some other document?

Thanks very much for any help
 
J

Jean-Guy Marcil

GaryatBeowulfs said:
I have a one page form that I need some help with. The form is used to track
daily account summaries and has space enough for two accounts. The problem is
there may be more than two accounts for that day. What I want to avoid is
having to open a new instance of the template for each two accounts.

Is there a way to insert new pages with the form layout as needed within the
same document? Like maybe a custom toolbar with an insert page button (how
would you do that?) or something? And while I'm thinking about it, if the
answer is a custom toolbar, can they be document specific? That is, would I
see the toolbar if I was working on some other document?

If you create a template (*.dot) and attach a toolbar to it, then the
toolbar will only be available when opening the template itself, or documents
created from the template.

As for your situation, I would create an AutoText entry text block for one
account. On your toolbar, just add two buttons: One to add an account at the
end of the document, and one to delete the current account at the cursor
position (If you allow people to add stuff, they will eventually add too much
and will need to delete some of it!)

Now, depending on the complexity of your template, it can be real easy or a
bit more complex... Without knowing more, it is difficult to tell!
 
G

GaryatBeowulfs

Jean-Guy Marcil said:
If you create a template (*.dot) and attach a toolbar to it, then the
toolbar will only be available when opening the template itself, or documents
created from the template.

As for your situation, I would create an AutoText entry text block for one
account. On your toolbar, just add two buttons: One to add an account at the
end of the document, and one to delete the current account at the cursor
position (If you allow people to add stuff, they will eventually add too much
and will need to delete some of it!)

Now, depending on the complexity of your template, it can be real easy or a
bit more complex... Without knowing more, it is difficult to tell!

Thank you for the quick response. As far as the complexity issue, each block
of account info is made up of a table made up of 9 rows and varying numbers
of columns (some cells merged etc) The cells contain various form fields -
text, check box and drop downs. Each account block takes up a little less
than half the page.

Can you get that fancy with autotext?
 
J

Jean-Guy Marcil

GaryatBeowulfs said:
Thank you for the quick response. As far as the complexity issue, each block
of account info is made up of a table made up of 9 rows and varying numbers
of columns (some cells merged etc) The cells contain various form fields -
text, check box and drop downs. Each account block takes up a little less
than half the page.

Can you get that fancy with autotext?

Of course! In fact, what you describe is not all that fancy!

When creating the Autotext, just select the table along with the following
paragraph mark (¶). This way, when the Autotext is inserted, the table
therein will not be merged with the preceding table.

If you need to refer to your formfields by name, you will need code to
rename each formfield.
 
G

GaryatBeowulfs

Jean-Guy Marcil said:
Of course! In fact, what you describe is not all that fancy!

When creating the Autotext, just select the table along with the following
paragraph mark (¶). This way, when the Autotext is inserted, the table
therein will not be merged with the preceding table.

If you need to refer to your formfields by name, you will need code to
rename each formfield.

Wow, thanks that was easy. Now, the form is protected so that is causing
autotext issues to I inserted an unprotected section at the bottom of the
form. This works and I am able to insert the autotext BUT this autotext is
unprotected.

Can protected forms be inserted as autotext? And how do you keep the table
from splitting across two pages, that is, I insert the autotext at the bottom
of the form and the top half of the autotext fits on the first page but the
bottom half goes to the next.

Thanks again for the help. It is much appreciated.
 
J

Jay Freedman

Wow, thanks that was easy. Now, the form is protected so that is causing
autotext issues to I inserted an unprotected section at the bottom of the
form. This works and I am able to insert the autotext BUT this autotext is
unprotected.

Can protected forms be inserted as autotext? And how do you keep the table
from splitting across two pages, that is, I insert the autotext at the bottom
of the form and the top half of the autotext fits on the first page but the
bottom half goes to the next.

Thanks again for the help. It is much appreciated.

First issue: Get rid of the unprotected section. Set up the macro with this kind
of sequence:

Dim myDoc As Document
Dim myRange As Range
Set myDoc = ActiveDocument

' unprotect if needed
If myDoc.ProtectionType <> wdNoProtection Then
myDoc.Unprotect
End If

' set location for insert
Set myRange = myDoc.Range
myRange.Collapse wdCollapseEnd

' insert new table AutoText
myDoc.AttachedTemplate.AutoTextEntries("NewTable") _
.Insert Where:=myRange, RichText:=True

' reprotect document
myDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
 
J

Jean-Guy Marcil

GaryatBeowulfs said:
Can protected forms be inserted as autotext? And how do you keep the table
from splitting across two pages, that is, I insert the autotext at the bottom
of the form and the top half of the autotext fits on the first page but the
bottom half goes to the next.

The first issue Re. protection was adressed by Jay.
This second one can be dealt with easily as well.

If I understand correclty, you always have space for two accounts on a page,
but if you insert a third one, it will sort of fit at the bottom of thew page
and then go on to the following page.

The easiest way of handling that is to make sure that all rows in your
Autotext table have the "Keep with Next" paragraph format setting enabled.
Just select your table, enable that setting from the Paragraph format
dialogue (Page and Line breaks tab) and then create the Autotext.

Done!
 
G

GaryatBeowulfs

Jay Freedman said:
First issue: Get rid of the unprotected section. Set up the macro with this kind
of sequence:

Dim myDoc As Document
Dim myRange As Range
Set myDoc = ActiveDocument

' unprotect if needed
If myDoc.ProtectionType <> wdNoProtection Then
myDoc.Unprotect
End If

' set location for insert
Set myRange = myDoc.Range
myRange.Collapse wdCollapseEnd

' insert new table AutoText
myDoc.AttachedTemplate.AutoTextEntries("NewTable") _
.Insert Where:=myRange, RichText:=True

' reprotect document
myDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.

Thank you, that works great except I have 2 small problems. When I run the
maco, the new table appends itself to the bottom of the previous table and
the other problem is that the form is password protected. How do I include
the password in the macro?

Thanks again
 
G

GaryatBeowulfs

Jean-Guy Marcil said:
The first issue Re. protection was adressed by Jay.
This second one can be dealt with easily as well.

If I understand correclty, you always have space for two accounts on a page,
but if you insert a third one, it will sort of fit at the bottom of thew page
and then go on to the following page.

The easiest way of handling that is to make sure that all rows in your
Autotext table have the "Keep with Next" paragraph format setting enabled.
Just select your table, enable that setting from the Paragraph format
dialogue (Page and Line breaks tab) and then create the Autotext.

Done!

The "Keep with Next" did the trick. However, the issue I'm having with the
protecting/unprotecting in the macro is that there is no handling of the
password in the macro. If I just protect the form without a password the
macro works great. It unprotects, inserts the table then reprotects the form.
I just need to be able to enter the password in the macro when it protects
and unprotects the document.
 
J

Jay Freedman

Thank you, that works great except I have 2 small problems. When I run the
maco, the new table appends itself to the bottom of the previous table and
the other problem is that the form is password protected. How do I include
the password in the macro?

Thanks again

For the "merging tables" problem: Did you follow Jean-Guy's instructions?

Also, does the template (and so each new document created from it) already
contain a table? If so, make sure there are _two_ paragraph marks after it. The
AutoText entry will then be inserted at the second one (the end of the
document), while the first one separates the two tables.

For the password, modify the myDoc.Unprotect line to

myDoc.Unprotect Password:="put your password here"

and modify the myDoc.Protect line to

myDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="put your
password here"

and replace the text in quotes with the actual password (also in quotes).
 
G

GaryatBeowulfs

Jay Freedman said:
For the "merging tables" problem: Did you follow Jean-Guy's instructions?


Also, does the template (and so each new document created from it) already
contain a table? If so, make sure there are _two_ paragraph marks after it. The
AutoText entry will then be inserted at the second one (the end of the
document), while the first one separates the two tables.

For the password, modify the myDoc.Unprotect line to

myDoc.Unprotect Password:="put your password here"

and modify the myDoc.Protect line to

myDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="put your
password here"

and replace the text in quotes with the actual password (also in quotes).

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.

It's working exactly how I wanted it to now. Thank you for the help

Gary
 
G

GaryatBeowulfs

Jean-Guy Marcil said:
The first issue Re. protection was adressed by Jay.
This second one can be dealt with easily as well.

If I understand correclty, you always have space for two accounts on a page,
but if you insert a third one, it will sort of fit at the bottom of thew page
and then go on to the following page.

The easiest way of handling that is to make sure that all rows in your
Autotext table have the "Keep with Next" paragraph format setting enabled.
Just select your table, enable that setting from the Paragraph format
dialogue (Page and Line breaks tab) and then create the Autotext.

Done!

Thank you for the help! Between you and Jay Freedman it's working like a
charm.

Gary
 

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