View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
quartz[_2_] quartz[_2_] is offline
external usenet poster
 
Posts: 441
Default 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.