我需要从 vb.net 打印 word.activedocument。我可以用document.printout() 做到这一点。但我需要将该文档打印到打印机的特定托盘。所以现在我正在使用printdocument.print()因为使用这行命令我可以定义要从中打印的特定页面,但我不知道如何将我的 word 文档转换或分配给这个 printdocument.print ???如果我的问题令人困惑,这是我的代码
Dim oWord As Word.Application = Globals.ThisAddIn.Application Dim app As Word.Document = oWord.ActiveDocument Dim objDataTypeMetafile As New Object objDataTypeMetafile = Word.WdPasteDataType.wdPasteMetafilePicture 'oWord.Visible = True Dim num_copies As String = tb_num_copies.Text 'oWord .PrintOut(Copies:=num_copies, PrintToFile:=False)
Dim prtdoc As New PrintDocument
Dim strDefaultPrinter As String = prtdoc.PrinterSettings.PrinterName
Dim strPrinter As String
For Each strPrinter In PrinterSettings.InstalledPrinters
com_printer.Items.Add(strPrinter)
If strPrinter = strDefaultPrinter Then
com_printer.SelectedIndex = com_printer.Items.IndexOf(strPrinter)
End If
Dim pkSource As Printing.PaperSource
Dim printDoc As New 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
printDoc.Print()
RemoveHandler printDoc.PrintPage, AddressOf Me.PrintPageHandler
End If
Next
Next strPrinter
oWord = Nothing
End Sub
Private Sub PrintPageHandler(ByVal sender As Object, ByVal args As Printing.PrintPageEventArgs) ?????????????????? 结束子