Restricting Number of Pages in a Word 2002 Template

  • Thread starter Thread starter Glenn
  • Start date Start date
G

Glenn

I have created a template containing 4 pages into which I
want people to enter data and save in normal word
template utilisation. I do not want them to be able to
increase the number of pages in the document from four.
Is there a way of setting the number of pages in the
template at four. Any info/recommendations much
appreciated.
 
Glenn said:
I have created a template containing 4 pages into which I
want people to enter data and save in normal word
template utilisation. I do not want them to be able to
increase the number of pages in the document from four.
Is there a way of setting the number of pages in the
template at four. Any info/recommendations much
appreciated.

Hi, Glenn,

There is no way to prevent the document from expanding as more text is
typed. All you can do is prevent the user from saving or printing the
document if it's too long.

You need to include macros in the template that intercept all the various
save and print commands. Each macro should display a message and then quit
if the document is too long, or carry out the original request if it's OK.

The list of macros needed is at
http://word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm. For an example,
the FileSave macro could look like this:

Public Sub FileSave()
On Error Resume Next
If ActiveDocument.Range _
.Information(wdNumberOfPagesInDocument) > 4 Then
MsgBox "You must not have more than four pages" _
& vbCr & "in this document.", vbCritical + vbOKOnly, _
"Document Not Saved"
Exit Sub
End If

ActiveDocument.Save
End Sub

If you need help getting the macros written and set up, please post in
microsoft.public.word.vba.beginners.
 
Back
Top