Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Limit number of pages (VB/Word 2003)

    Hi!

    Can anyone tell me if it's possible to limited the number of pages in a document please? Our BDU team produce publications which should only be two pages long, printed double-sided. I've searched for some other posts and all I can see is the suggestion to have a message box at the point of save/saveas warning the user if they have taken more than two pages. If that's all that can be done I'll just have to go with that ;-)

    Thanks in advance,

    Violet

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Limit number of pages (VB/Word 2003)

    A warning before saving the document would be my recommendation too. Code that constantly monitors the number of pages as the user types would probably have a negative impact on performance.

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Limit number of pages (VB/Word 2003)

    This could be done as an app_DocumentChange event.

    This is tricky to set up (instructions can be found here), and can have a significant impact on performance as it runs every time any change is made to any document!

    Something like...

    <code>
    Public Sub App_DocumentChange()

    Const intPageMax As Integer = 2
    Const strTitle As String = "Document page limit"
    Const strMessage As String = "This document has a limit of " & Str(intPageMax) & " pages, your change has been undone."

    If ActiveDocument.ActiveWindow.Panes(1).Pages.Count > intPageMax Then
    ActiveDocument.Undo
    MsgBox strMessage, vbCritical + vbOKOnly, strTitle
    End If

    End Sub
    </code>

    I haven't tested this code, and I don't recommend using it, but just so you know that this is possible. You would also need to add a way to identify the correct target document and add another test at the beginning to exit if this is not your document, this could be by checking the filename or looking for a document variable, or...

    StuartR

  4. #4
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Limit number of pages (VB/Word 2003)

    Thanks Hans and Stuart - the person who asked has a Mac and I know there is scope for doing that on a Mac more easily than a PC so I will leave it alone!

    Have a nice day!

    Violet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •