Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete entire page 2 so document shows as 1 page only Elinita New Users to Excel 1 November 22nd 09 06:35 PM
PROBLEM:How to squeeze 2 Page sized Chart in Excel 2000 & embed in Word 2000 and print from Word to fit one page ??? [email protected] Excel Discussion (Misc queries) 2 September 10th 08 11:07 AM
PROBLEM:How to squeeze 2 Page sized Chart in Excel 2000 & embed in Word 2000 and print from Word to fit one page ??? [email protected] New Users to Excel 2 September 10th 08 11:07 AM
How do you print Exel gridlines on the entire page ? ndwilsonnorwin Excel Discussion (Misc queries) 3 September 8th 05 07:25 PM
How do you format a sheet to fill the entire page to print? Lindsay Excel Discussion (Misc queries) 1 June 28th 05 09:17 PM


All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"