0
我需要將活動文檔打印到特定紙盒。 例如,如果用戶點擊該按鈕函的文件應從紙盤2 此刻打印我使用Word文檔從特定紙盒打印
Dim word As Word.Application = Globals.ThisAddIn.Application
Dim pd As New PrintDialog()
pd.PrinterSettings = New PrinterSettings()
If pd.ShowDialog() = DialogResult.OK Then
word.PrintOut()
End If
我設法如果我用做與此相關的一些工作的代碼,這一塊基本屬性prindocument()。財產以後像
昏暗pkSource作爲Printing.PaperSource 昏暗printDoc作爲新的PrintDocument 「的AddHandler printDoc.PrintPage
printDoc.PrinterSettings.PrinterName = strPrinter
For Each pkSource In printDoc.PrinterSettings.PaperSources
If pkSource.RawKind = "261" Then
printDoc.PrinterSettings.DefaultPageSettings.PaperSource.RawKind = pkSource.RawKind
Dim psize As Printing.PaperSize = printDoc.PrinterSettings.PaperSizes.Item(5)
printDoc.DefaultPageSettings.PaperSize = psize
printDoc.PrinterSettings.PrintRange = PrintRange.AllPages
'AddHandler printDoc.PrintPage, AddressOf Me.PrintDoc_PrintPage
printDoc.PrinterSettings.Copies = num_copies
printDoc.PrinterSettings.Duplex = Duplex.Default
AddHandler printDoc.PrintPage, AddressOf Me.PrintPageHandler
'PrintDocument1 = oWord.ActiveDocument
Try
'PrintDocument1.Print()
printDoc = app
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
'printDoc.Print()
' MsgBox("printed")
RemoveHandler printDoc.PrintPage, AddressOf Me.PrintPageHandler
End If
Next
但我不希望因爲我需要打印激活Word文檔使用打印文檔。
Thansk For reply。對不起,我不是那麼好,如果你可以請給我任何例子它將是非常有益的,與(firstPageTray和其他PagesTray)合作...謝謝 –
昏暗的WD作爲Word.Application = Globals.ThisAddIn.Application 昏暗的DOC作爲Word.Document = wd.ActiveDocument doc.PageSetup.FirstPageTray = 262 doc.PageSetup.OtherPagesTray = 262 'doc.PrintOut() –
這應該有效。指針值很長。有多種方法可以獲取紙盤ID(即長整數)以及紙盤名稱的列表。 –