PrintOut 方法
請參閱套用至範例特定套用於 Application、Document 及 Window 物件時的 PrintOut 方法。
列印整份或部份指定文件。
expression.PrintOut(Background, Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType, PrintToFile, Collate, FileName, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight)
expression 必選。傳回上述其中一種物件的運算式。
Background 選擇性 Variant。設為 True 表示在 Microsoft Word 列印文件時,繼續執行巨集。
Append 選擇性 Variant。設為 True 表示將指定的文件附加於 OutputFileName 引數所指定的檔案名稱後面;設為 False 表示覆寫 OutputFileName 中的內容。
Range 選擇性 Variant。代表頁面範圍。此引數可以是任意的 WdPrintOutRange 常數。
wdPrintAllDocument
wdPrintCurrentPage
wdPrintFromTo
wdPrintRangeOfPages
wdPrintSelection
OutputFileName 選擇性 Variant。當 PrintToFile 設定為 True 時,此引數指定輸出檔案的路徑及檔案名稱。
From 選擇性 Variant。代表 Range 設定為 wdPrintFromTo 時的起始頁碼。
To 選擇性 Variant。代表 Range 設定為 wdPrintFromTo 時的結束頁碼。
Item 選擇性 Variant。代表列印的項目。此引數可以是任意的 WdPrintOutItem 常數。
wdPrintAutoTextEntries
wdPrintComments
wdPrintDocumentContent
wdPrintDocumentWithMarkup
wdPrintEnvelope
wdPrintKeyAssignments
wdPrintMarkup
wdPrintProperties
wdPrintStyles
Copies 選擇性 Variant。代表列印份數。
Pages 選擇性 Variant。代表列印的頁碼及頁面範圍,各項目之間以逗點分隔。例如,「2, 6-10」表示列印第 2 頁及第 6 到第 10 頁。
PageType 選擇性 Variant。代表列印的頁面類型。此引數可以是任意的 WdPrintOutPages 常數。
wdPrintAllPages
wdPrintEvenPagesOnly
wdPrintOddPagesOnly
PrintToFile 選擇性 Variant。True 表示傳送列印指令到檔案。請確定已使用 OutputFileName 指定了檔案名稱。
Collate 選擇性 Variant。當列印文件的多份副本時,設為 True 表示表示在列印下一份副本前,先列印整份文件。
FileName 選擇性 Variant。代表列印的文件路徑及檔案名稱。如果省略此引數,Word 便列印使用中文件。(僅適用於 Application 物件。)
ActivePrinterMacGX 選擇性 Variant。此引數僅適用於 Microsoft Office Macintosh 版本。如需有關此引數的其他資訊,請參考 Microsoft Office Macintosh 版本所附的語言參照 [說明]。
ManualDuplexPrint 選擇性 Variant。True 表示在沒有雙面列印設備的印表機上列印一份雙面文件。當此引數為 True 時,則忽略 PrintBackground 及 PrintReverse 屬性。若要控制手動雙面列印期間的輸出,請使用 PrintOddPagesInAscendingOrder 及 PrintEvenPagesInAscendingOrder 屬性。此引數對您而言可能無效;有效與否,須視您所選取或安裝的語言支援 (例如:美式英文) 而定。
PrintZoomColumn 選擇性 Variant。代表 Word 要在單一頁面上橫向排列的頁數。此引數可以是 1,2,3,或 4。併用此引數與 PrintZoomRow 引數時,則可在單張紙上列印多頁。
PrintZoomRow 選擇性 Variant。代表 Word 要在單一頁面上縱向排列的頁數。此引數可以是 1,2,3,或 4。併用此引數與 PrintZoomColumn 引數時,則可在單張紙上列印多頁。
PrintZoomPaperWidth 選擇性 Variant。代表 Word 所要調整的列印頁面寬度,以 twips 為單位 (20 twips = 1 點;72 點 = 1 英吋)。
PrintZoomPaperHeight 選擇性 Variant。代表 Word 所要調整的列印頁面高度,以 twips 為單位 (20 twips = 1 點;72 點 = 1 英吋)。
範例
套用至 Application、Document 及 Window 物件時。
本範例列印使用中文件的目前頁面。
ActiveDocument.PrintOut Range:=wdPrintCurrentPage
本範例列印目前資料夾中的所有文件。Dir 函數的作用在於傳回副檔名為「.doc」的所有檔案名稱。
adoc = Dir("*.DOC")
Do While adoc <> ""
Application.PrintOut FileName:=adoc
adoc = Dir()
Loop
本範例列印使用中視窗內的文件前三頁。
ActiveDocument.ActiveWindow.PrintOut _
Range:=wdPrintFromTo, From:="1", To:="3"
本範例列印使用中文件上的註解。
If ActiveDocument.Comments.Count >= 1 Then
ActiveDocument.PrintOut Item:=wdPrintComments
End If
本範例列印使用中文件,每一張紙列印六頁。
ActiveDocument.PrintOut PrintZoomColumn:=3, _
PrintZoomRow:=2
本範例以實際尺寸的 75% 比例來列印使用中文件。
ActiveDocument.PrintOut _
PrintZoomPaperWidth:=0.75 * (8.5 * 1440), _
PrintZoomPaperHeight:=0.75 * (11 * 1440)
==> 本文由 "YiChungChou <YiChu...@discussions.microsoft.com>"
> 於 news:B06E1C51-6B03-4CF7-B3AD-493C23F7F745%40microsoft.com 發表
> 謝謝回覆.
> 在 Dim PWord As Word.Document = New Word.Document 宣告後
> 試著用PWord.PrintOut("C:\FileName.Doc"), 卻顯示 "類型不相符"
> 不知應如何呼叫, 或有範例可供參考?
> 謝謝!
> "璉璉" 來函:
> > 請呼叫 Word 內 PrintOut 方法。
> >
> > ==> 本文由 "YiChungChou <YiChu...@discussions.microsoft.com>"
> > > 於 news:0FE579D5-AF0A-4F22-AF81-F8F26077ABF3%40microsoft.com 發表
> > > 利用System.Drawing.Printing.PrintDocument的物件, 只能列印.txt及.rtf, 為了能直接列印Word檔案
> > > 新增了Word的參考到專案內, 並作宣告
> > > Dim PWord As Word.Document = New Word.Document
> > > 並作如下的設定
> > > PWord = DirectCast("C:\FileName.Doc", Word.Document)
> > > OpenFormName.Paste(PWord)
> > > 只是一直無法成功, 並顯示轉換無效
> > > 煩請指教, 謝謝!
> > >
> >
--
風禹科技驗證有限公司 ASP.NET Web News Reader 0.2.7 UTF-8 Beta
網站地圖 http://tlcheng.twbbs.org/wwwmap.htm
流域防洪/區域水資源/徐昇網/玫瑰圖/語音通訊 文章與程式
Basic/Fortran/Windows API/.Net/輔助說明檔 原始碼、文章與討論
微軟程式設計、系統管理使用新技術論壇討論區,網友回覆後即時簡訊、電子郵件通知:
MSDN: http://forums.microsoft.com/msdn-cht/default.aspx?siteid=14
TechNet: http://forums.microsoft.com/technet-cht/default.aspx?siteid=23
--
ASPNET News Reader http://tlcheng.twbbs.org/News/Reader.aspx
RSS 2.0 http://tlcheng.twbbs.org/News/rss2.aspx?Action=List&Newsgroup=microsoft.public.tw.dotnet.vsnet
"璉璉" 來函: