+ Reply to Thread
Results 1 to 2 of 2

Automating Word - Print one page not entire document!

  1. #1
    quartz
    Guest

    Automating Word - Print one page not entire document!

    I am using VBA in Excel XP with Windows 2000.

    I have a program in which the user can click a button and print a page from
    a Word document. The problem is, the entire document prints. I have tried
    several different settings, but nothing seems to work. Could someone please
    examine my code and determine what is wrong? My latest code follows:

    Dim wrdApp As Word.Application
    Set wrdApp = CreateObject("Word.Application")
    wrdApp.Application.Documents.Open _
    strSourceFilePath & strSourceFileName, _
    False, _
    True, _
    False, _
    "", _
    "", _
    False

    wrdApp.Visible = True
    wrdApp.Activate

    wrdApp.Application.PrintOut _
    Filename:="", _
    Range:=wdPrintFromTo, _
    From:=2, _
    To:=2, _
    Item:=wdPrintDocumentContent, _
    Copies:=1, _
    Pages:="", _
    ManualDuplexPrint:=False, _
    Collate:=True, _
    Background:=True, _
    PrintToFile:=False, _
    PrintZoomColumn:=0, _
    PrintZoomRow:=0, _
    PrintZoomPaperWidth:=0, _
    PrintZoomPaperHeight:=0

    wrdApp.ActiveDocument.Close SaveChanges:=False
    wrdApp.Quit
    Set wrdApp = Nothing

    Thanks in advance.

  2. #2
    Tom Ogilvy
    Guest

    Re: Automating Word - Print one page not entire document!

    this is what I recorded: Printing pages 2 to 3

    Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
    wdPrintDocumentContent, Copies:=1, Pages:="2-3", PageType:= _
    wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True,
    Background:= _
    True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
    PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0

    And to only print page 2

    Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
    wdPrintDocumentContent, Copies:=1, Pages:="2",
    PageType:=wdPrintAllPages, _
    ManualDuplexPrint:=False, Collate:=True, Background:=True,
    PrintToFile:= _
    False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0,
    _
    PrintZoomPaperHeight:=0

    Word 2002.

    --
    Regards,
    Tom Ogilvy

    "quartz" <[email protected]> wrote in message
    news:[email protected]...
    > I am using VBA in Excel XP with Windows 2000.
    >
    > I have a program in which the user can click a button and print a page

    from
    > a Word document. The problem is, the entire document prints. I have tried
    > several different settings, but nothing seems to work. Could someone

    please
    > examine my code and determine what is wrong? My latest code follows:
    >
    > Dim wrdApp As Word.Application
    > Set wrdApp = CreateObject("Word.Application")
    > wrdApp.Application.Documents.Open _
    > strSourceFilePath & strSourceFileName, _
    > False, _
    > True, _
    > False, _
    > "", _
    > "", _
    > False
    >
    > wrdApp.Visible = True
    > wrdApp.Activate
    >
    > wrdApp.Application.PrintOut _
    > Filename:="", _
    > Range:=wdPrintFromTo, _
    > From:=2, _
    > To:=2, _
    > Item:=wdPrintDocumentContent, _
    > Copies:=1, _
    > Pages:="", _
    > ManualDuplexPrint:=False, _
    > Collate:=True, _
    > Background:=True, _
    > PrintToFile:=False, _
    > PrintZoomColumn:=0, _
    > PrintZoomRow:=0, _
    > PrintZoomPaperWidth:=0, _
    > PrintZoomPaperHeight:=0
    >
    > wrdApp.ActiveDocument.Close SaveChanges:=False
    > wrdApp.Quit
    > Set wrdApp = Nothing
    >
    > Thanks in advance.




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1