2015-10-29 92 views

回答

1

是的。您可以打印到这样的默认打印机:

Sub PrintFile(ByVal fileName As String) 
    Dim myFile As New ProcessStartInfo 
    With myFile 
     .UseShellExecute = True 
     .WindowStyle = ProcessWindowStyle.Hidden 
     .FileName = fileName 
     .Verb = "Print" 
    End With 
    Process.Start(myFile) 
End Sub 

更多细节及交代有关此工作原理可以在我的文章在这里找到: https://pradeep1210.wordpress.com/2010/03/26/easy-way-to-print-files-to-default-printer/

+0

我在文件名末尾看到一个额外的“')'”。纠正并希望它应该起作用。 –

+0

谢谢!它工作,但我有另一个问题,当我按打印(按钮)它打开我的Excel文件,我想打印.. –

+0

这应该发生只有当没有安装打印机或系统有一些其他问题。上面的代码与右键单击文件并单击弹出菜单中的“打印”选项相当。所以,如果这有效,这段代码也应该工作。 –

相关问题