![]() |
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. |
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. |
All times are GMT +1. The time now is 02:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com