2010-06-02 144 views
5

我的打印机名称为\\abc\First Floor A-Block其取名为\ abc \ NE04上的一楼A块。我应该如何打印通过VB.net打印word文档中的活动打印机问题

Private oWord As Word.Application 

Dim lobjDoc As Word.Document 

Dim strFolder as String 
Dim pd As New PrintDocument 
Dim strPrintername as String 
oWord = CreateObject("Word.Application") 
oWord.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone 
oWord.ActivePrinter =strPrintername 
strFolder="D:\testdoc.prn" 

“在这里,我给它是网络上的打印机名称,但其采取的名字

\ ABC \一楼A块上NE04:

lobjDoc = oWord.Documents.Open(CType(strFolder, Object)) 

lobjDoc.PageSetup.FirstPageTray = Word.WdPaperTray.wdPrinterAutomaticSheetFeed 

lobjDoc.PageSetup.OtherPagesTray = Word.WdPaperTray.wdPrinterAutomaticSheetFeed 

lobjDoc.PrintOut(Background:=False, Append:=False, OutputFileName:=strFolder, PrintToFile:=True) 'here its giving error about printer settings 

lobjDoc.Close(SaveChanges:=False) 

有没有什么办法通过打印word文档及其所有内容PrintDocument

感谢

回答

4

你可以试试这个:

首先使用Windows打印机设置来设置该打印机为默认打印机。 然后用手打开Word并打开VBA编辑器,转到立即窗口并键入?ActivePrinter

这应该有希望为您提供确切格式的打印机名称,您需要发送Word以识别它。