Consulting

Results 1 to 5 of 5

Thread: Solved: Print last page

  1. #1
    VBAX Newbie
    Joined
    Oct 2005
    Posts
    3
    Location

    Solved: Print last page

    Hi,

    I am trying to create a macro in Word Xp to print out the last page of a document (could be page 3 or 4 or 5 depending on the contents) to a different printer to the rest of the document.

    I am working along the lines of ActiveDocument.PrintOut Range:=

    But I am unsure of how to specify the last page after Range:= as it varies on each printout.

    Any help will be greatly appreciated

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    A couple of ways.

    1. Move selection to the last page, then simply make the Print instruction to print the current page.
    [vba]Selection.EndKey unit:=wdStory
    Application.PrintOut FileName:="", _
    Range:=wdPrintCurrentPage[/vba]

    2. Make a Selection of the last page, then print the Selection.
    [vba]Selection.EndKey unit:=wdStory
    ActiveDocument.Bookmarks("\page").Range.Select
    Application.PrintOut FileName:="", _
    Range:=wdPrintSelection[/vba]

  3. #3
    VBAX Newbie
    Joined
    Oct 2005
    Posts
    3
    Location
    Thanks for the help - I will try these later.

    Wez

  4. #4
    VBAX Newbie
    Joined
    Oct 2005
    Posts
    3
    Location
    Works exactly as i wanted - many thanks again

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Wez welcome to VBAX!

    Don't forget to mark your thread solved.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

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